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

Commit b3a3f0a

Browse files
committed
filesystem: add a new test for EncodedObjectSize
Suggested by taruti. Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
1 parent 5c471c3 commit b3a3f0a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

storage/filesystem/object.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ func (s *ObjectStorage) encodedObjectSizeFromPackfile(h plumbing.Hash) (
205205
if ok {
206206
return obj.Size(), nil
207207
}
208-
}
209-
210-
if err != nil && err != plumbing.ErrObjectNotFound {
208+
} else if err != nil && err != plumbing.ErrObjectNotFound {
211209
return 0, err
212210
}
213211

storage/filesystem/object_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ func (s *FsSuite) TestGetSizeFromPackfile(c *C) {
107107
})
108108
}
109109

110+
func (s *FsSuite) TestGetSizeOfAllObjectFiles(c *C) {
111+
fs := fixtures.ByTag(".git").One().DotGit()
112+
o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
113+
114+
// Get the size of `tree_walker.go`.
115+
err := o.ForEachObjectHash(func(h plumbing.Hash) error {
116+
size, err := o.EncodedObjectSize(h)
117+
c.Assert(err, IsNil)
118+
c.Assert(size, Not(Equals), int64(0))
119+
return nil
120+
})
121+
c.Assert(err, IsNil)
122+
}
123+
110124
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
111125
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
112126
o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())

0 commit comments

Comments
 (0)