aboutsummaryrefslogtreecommitdiffstats
path: root/storage/transactional/object_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/transactional/object_test.go')
-rw-r--r--storage/transactional/object_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/storage/transactional/object_test.go b/storage/transactional/object_test.go
index ff8cd4e..10b6318 100644
--- a/storage/transactional/object_test.go
+++ b/storage/transactional/object_test.go
@@ -117,3 +117,37 @@ func (s *ObjectSuite) TestIterEncodedObjects(c *C) {
c.Assert(hashes[0], Equals, ch)
c.Assert(hashes[1], Equals, th)
}
+
+func (s *ObjectSuite) TestCommit(c *C) {
+ base := memory.NewStorage()
+ temporal := memory.NewStorage()
+
+ os := NewObjectStorage(base, temporal)
+
+ commit := base.NewEncodedObject()
+ commit.SetType(plumbing.CommitObject)
+
+ _, err := os.SetEncodedObject(commit)
+ c.Assert(err, IsNil)
+
+ tree := base.NewEncodedObject()
+ tree.SetType(plumbing.TreeObject)
+
+ _, err = os.SetEncodedObject(tree)
+ c.Assert(err, IsNil)
+
+ err = os.Commit()
+ c.Assert(err, IsNil)
+
+ iter, err := base.IterEncodedObjects(plumbing.AnyObject)
+ c.Assert(err, IsNil)
+
+ var hashes []plumbing.Hash
+ err = iter.ForEach(func(obj plumbing.EncodedObject) error {
+ hashes = append(hashes, obj.Hash())
+ return nil
+ })
+
+ c.Assert(err, IsNil)
+ c.Assert(hashes, HasLen, 2)
+}