diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2018-04-16 11:05:01 -0700 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2018-04-16 11:06:17 -0700 |
commit | 79db8cf8bf477c2bb9d01cbe289fbeaccaa1ee65 (patch) | |
tree | c0c3bd3b9e6a7604bccefb1024480643ad7f74e4 | |
parent | 6ea601633ef7c2aba24bd4832305005a5f7f4f98 (diff) | |
download | go-git-79db8cf8bf477c2bb9d01cbe289fbeaccaa1ee65.tar.gz |
dotgit: add test for bad file in pack directory
Suggested by mcuadros.
Issue: src-d/go-git#807
Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit_test.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go index 2c43295..3e2c4fd 100644 --- a/storage/filesystem/internal/dotgit/dotgit_test.go +++ b/storage/filesystem/internal/dotgit/dotgit_test.go @@ -418,7 +418,7 @@ func findReference(refs []*plumbing.Reference, name string) *plumbing.Reference return nil } -func (s *SuiteDotGit) TestObjectsPack(c *C) { +func (s *SuiteDotGit) TestObjectPacks(c *C) { f := fixtures.Basic().ByTag(".git").One() fs := f.DotGit() dir := New(fs) @@ -427,6 +427,18 @@ func (s *SuiteDotGit) TestObjectsPack(c *C) { c.Assert(err, IsNil) c.Assert(hashes, HasLen, 1) c.Assert(hashes[0], Equals, f.PackfileHash) + + // Make sure that a random file in the pack directory doesn't + // break everything. + badFile, err := fs.Create("objects/pack/OOPS_THIS_IS_NOT_RIGHT.pack") + c.Assert(err, IsNil) + err = badFile.Close() + c.Assert(err, IsNil) + + hashes2, err := dir.ObjectPacks() + c.Assert(err, IsNil) + c.Assert(hashes2, HasLen, 1) + c.Assert(hashes[0], Equals, hashes2[0]) } func (s *SuiteDotGit) TestObjectPack(c *C) { |