Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 9013dde

Browse files
committed
storage/filesystem: add KeepDescriptors test
Also delete Close from MockObjectStorage and memory storer. Signed-off-by: Javi Fontan <jfontan@gmail.com>
1 parent 5260b87 commit 9013dde

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

plumbing/storer/object_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,3 @@ func (o *MockObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (EncodedOb
157157
func (o *MockObjectStorage) Begin() Transaction {
158158
return nil
159159
}
160-
161-
func (o *MockObjectStorage) Close() error {
162-
return nil
163-
}

storage/filesystem/object_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,37 @@ func (s *FsSuite) TestGetFromPackfile(c *C) {
4848
})
4949
}
5050

51+
func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
52+
fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
53+
fs := f.DotGit()
54+
dg := dotgit.NewWithOptions(fs, dotgit.Options{KeepDescriptors: true})
55+
o, err := NewObjectStorageWithOptions(dg, Options{KeepDescriptors: true})
56+
c.Assert(err, IsNil)
57+
58+
expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
59+
obj, err := o.EncodedObject(plumbing.AnyObject, expected)
60+
c.Assert(err, IsNil)
61+
c.Assert(obj.Hash(), Equals, expected)
62+
63+
packfiles, err := dg.ObjectPacks()
64+
c.Assert(err, IsNil)
65+
66+
pack1, err := dg.ObjectPack(packfiles[0])
67+
c.Assert(err, IsNil)
68+
69+
err = o.Close()
70+
c.Assert(err, IsNil)
71+
72+
pack2, err := dg.ObjectPack(packfiles[0])
73+
c.Assert(err, IsNil)
74+
c.Assert(pack1, Not(Equals), pack2)
75+
76+
err = o.Close()
77+
c.Assert(err, IsNil)
78+
79+
})
80+
}
81+
5182
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
5283
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
5384
o, err := NewObjectStorage(dotgit.New(fs))

storage/memory/storage.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ func (o *ObjectStorage) ObjectPacks() ([]plumbing.Hash, error) {
183183
func (o *ObjectStorage) DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) error {
184184
return nil
185185
}
186-
func (s *ObjectStorage) Close() error {
187-
return nil
188-
}
189186

190187
var errNotSupported = fmt.Errorf("Not supported")
191188

0 commit comments

Comments
 (0)