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

Commit 79db8cf

Browse files
committed
dotgit: add test for bad file in pack directory
Suggested by mcuadros. Issue: #807 Signed-off-by: Jeremy Stribling <[email protected]>
1 parent 6ea6016 commit 79db8cf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

storage/filesystem/internal/dotgit/dotgit_test.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func findReference(refs []*plumbing.Reference, name string) *plumbing.Reference
418418
return nil
419419
}
420420

421-
func (s *SuiteDotGit) TestObjectsPack(c *C) {
421+
func (s *SuiteDotGit) TestObjectPacks(c *C) {
422422
f := fixtures.Basic().ByTag(".git").One()
423423
fs := f.DotGit()
424424
dir := New(fs)
@@ -427,6 +427,18 @@ func (s *SuiteDotGit) TestObjectsPack(c *C) {
427427
c.Assert(err, IsNil)
428428
c.Assert(hashes, HasLen, 1)
429429
c.Assert(hashes[0], Equals, f.PackfileHash)
430+
431+
// Make sure that a random file in the pack directory doesn't
432+
// break everything.
433+
badFile, err := fs.Create("objects/pack/OOPS_THIS_IS_NOT_RIGHT.pack")
434+
c.Assert(err, IsNil)
435+
err = badFile.Close()
436+
c.Assert(err, IsNil)
437+
438+
hashes2, err := dir.ObjectPacks()
439+
c.Assert(err, IsNil)
440+
c.Assert(hashes2, HasLen, 1)
441+
c.Assert(hashes[0], Equals, hashes2[0])
430442
}
431443

432444
func (s *SuiteDotGit) TestObjectPack(c *C) {

0 commit comments

Comments
 (0)