diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-11 17:25:13 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-22 13:49:25 +0000 |
commit | d83d6ad7230eb27afae4169330681967bb20dcfa (patch) | |
tree | b58a3161b9314a3e7ed1db5e4cc5108fa49ab81a /morphlib/gitdir_tests.py | |
parent | ef590d30ca978f57b658f59f584b9785f40ed0a5 (diff) | |
download | morph-d83d6ad7230eb27afae4169330681967bb20dcfa.tar.gz |
GitDir: add store_blob method
This is needed for making commits without touching the workspace.
Diffstat (limited to 'morphlib/gitdir_tests.py')
-rw-r--r-- | morphlib/gitdir_tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/morphlib/gitdir_tests.py b/morphlib/gitdir_tests.py index a2e530f1..395ee2e5 100644 --- a/morphlib/gitdir_tests.py +++ b/morphlib/gitdir_tests.py @@ -160,6 +160,19 @@ class GitDirectoryContentsTests(unittest.TestCase): self.assertEqual(len(tree), 40) self.assertNotEqual(commit, tree) + def test_store_blob_with_string(self): + gd = morphlib.gitdir.GitDirectory(self.dirname) + sha1 = gd.store_blob('test string') + self.assertEqual('test string', gd.get_blob_contents(sha1)) + + def test_store_blob_with_file(self): + gd = morphlib.gitdir.GitDirectory(self.dirname) + with open(os.path.join(self.tempdir, 'blob'), 'w') as f: + f.write('test string') + with open(os.path.join(self.tempdir, 'blob'), 'r') as f: + sha1 = gd.store_blob(f) + self.assertEqual('test string', gd.get_blob_contents(sha1)) + def test_uncommitted_changes(self): gd = morphlib.gitdir.GitDirectory(self.dirname) self.assertEqual(sorted(gd.get_uncommitted_changes()), |