Skip to content

Commit

Permalink
filesystem: add a new test for EncodedObjectSize
Browse files Browse the repository at this point in the history
Suggested by taruti.

Signed-off-by: Jeremy Stribling <[email protected]>
  • Loading branch information
strib committed Oct 12, 2018
1 parent 5c471c3 commit b3a3f0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions storage/filesystem/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ func (s *ObjectStorage) encodedObjectSizeFromPackfile(h plumbing.Hash) (
if ok {
return obj.Size(), nil
}
}

if err != nil && err != plumbing.ErrObjectNotFound {
} else if err != nil && err != plumbing.ErrObjectNotFound {
return 0, err
}

Expand Down
14 changes: 14 additions & 0 deletions storage/filesystem/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ func (s *FsSuite) TestGetSizeFromPackfile(c *C) {
})
}

func (s *FsSuite) TestGetSizeOfAllObjectFiles(c *C) {
fs := fixtures.ByTag(".git").One().DotGit()
o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())

// Get the size of `tree_walker.go`.
err := o.ForEachObjectHash(func(h plumbing.Hash) error {
size, err := o.EncodedObjectSize(h)
c.Assert(err, IsNil)
c.Assert(size, Not(Equals), int64(0))
return nil
})
c.Assert(err, IsNil)
}

func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
Expand Down

0 comments on commit b3a3f0a

Please sign in to comment.