diff options
Diffstat (limited to 'file_test.go')
-rw-r--r-- | file_test.go | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/file_test.go b/file_test.go index d9024b0..aa3369a 100644 --- a/file_test.go +++ b/file_test.go @@ -2,10 +2,8 @@ package git import ( "io" - "os" "gopkg.in/src-d/go-git.v3/core" - "gopkg.in/src-d/go-git.v3/formats/packfile" . "gopkg.in/check.v1" ) @@ -18,28 +16,11 @@ var _ = Suite(&SuiteFile{}) // create the repositories of the fixtures func (s *SuiteFile) SetUpSuite(c *C) { - fixtureRepos := [...]struct { - url string - packfile string - }{ + fileFixtures := []packedFixture{ {"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"}, {"https://github.com/cpcs499/Final_Pres_P", "formats/packfile/fixtures/Final_Pres_P.ofs-delta"}, } - s.repos = make(map[string]*Repository, 0) - for _, fixRepo := range fixtureRepos { - s.repos[fixRepo.url] = NewPlainRepository() - - d, err := os.Open(fixRepo.packfile) - c.Assert(err, IsNil) - - r := packfile.NewReader(d) - r.Format = packfile.OFSDeltaFormat - - _, err = r.Read(s.repos[fixRepo.url].Storage) - c.Assert(err, IsNil) - - c.Assert(d.Close(), IsNil) - } + s.repos = unpackFixtures(c, fileFixtures) } type fileIterExpectedEntry struct { @@ -77,6 +58,8 @@ func (s *SuiteFile) TestIter(c *C) { expected := t.files[k] file, err := iter.Next() c.Assert(err, IsNil, Commentf("subtest %d, iter %d, err=%v", i, k, err)) + c.Assert(file.Hash.IsZero(), Equals, false) + c.Assert(file.Hash, Equals, file.ID()) c.Assert(file.Name, Equals, expected.Name, Commentf("subtest %d, iter %d, name=%s, expected=%s", i, k, file.Name, expected.Hash)) c.Assert(file.Hash.String(), Equals, expected.Hash, Commentf("subtest %d, iter %d, hash=%v, expected=%s", i, k, file.Hash.String(), expected.Hash)) } |