aboutsummaryrefslogtreecommitdiffstats
path: root/storage/transactional/object_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-12-10 20:18:50 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2018-12-10 20:18:50 +0100
commit12dc3ef13e5c783b9e304aa8b6a2f7097880ab87 (patch)
tree9425626a16f47f73fc7dd2128d1ea51b5d1be5a3 /storage/transactional/object_test.go
parenta2b39f540e5b07cf361b530e19de30707b8ca0d7 (diff)
downloadgo-git-12dc3ef13e5c783b9e304aa8b6a2f7097880ab87.tar.gz
storage: transactional, new storage with transactional capabilities
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
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)
+}