aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-09-05 11:01:06 +0200
committerJavi Fontan <jfontan@gmail.com>2018-09-05 11:01:06 +0200
commit9013dde72d0387a74b728ee336019728ba159d1c (patch)
tree8e3149e628f50db829ad0f94b9b8172376cd046f /storage/filesystem
parent5260b87fd08f70df6f1eb297ccb04d74d32dd6c8 (diff)
downloadgo-git-9013dde72d0387a74b728ee336019728ba159d1c.tar.gz
storage/filesystem: add KeepDescriptors test
Also delete Close from MockObjectStorage and memory storer. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'storage/filesystem')
-rw-r--r--storage/filesystem/object_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index b1408b7..6feb6ae 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -48,6 +48,37 @@ func (s *FsSuite) TestGetFromPackfile(c *C) {
})
}
+func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
+ fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
+ fs := f.DotGit()
+ dg := dotgit.NewWithOptions(fs, dotgit.Options{KeepDescriptors: true})
+ o, err := NewObjectStorageWithOptions(dg, Options{KeepDescriptors: true})
+ c.Assert(err, IsNil)
+
+ expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ obj, err := o.EncodedObject(plumbing.AnyObject, expected)
+ c.Assert(err, IsNil)
+ c.Assert(obj.Hash(), Equals, expected)
+
+ packfiles, err := dg.ObjectPacks()
+ c.Assert(err, IsNil)
+
+ pack1, err := dg.ObjectPack(packfiles[0])
+ c.Assert(err, IsNil)
+
+ err = o.Close()
+ c.Assert(err, IsNil)
+
+ pack2, err := dg.ObjectPack(packfiles[0])
+ c.Assert(err, IsNil)
+ c.Assert(pack1, Not(Equals), pack2)
+
+ err = o.Close()
+ c.Assert(err, IsNil)
+
+ })
+}
+
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
o, err := NewObjectStorage(dotgit.New(fs))