diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-03-08 23:30:52 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-03-08 23:30:52 +0100 |
commit | b35fc295b4ac531adc72fc83f2af628c7c163c0e (patch) | |
tree | 0282f20de8279db354233d1d67e3743e08509020 /tree_test.go | |
parent | 9c9cdff966cc181296f400769d3c8596f17e743a (diff) | |
parent | 9e6a03b7956464ccd9d2fbacedd8e5cc23572d02 (diff) | |
download | go-git-b35fc295b4ac531adc72fc83f2af628c7c163c0e.tar.gz |
Merge pull request #39 from scjalliance/git-object-interface
Added Object interface for Commit, Tree, Blob and Tag
Diffstat (limited to 'tree_test.go')
-rw-r--r-- | tree_test.go | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/tree_test.go b/tree_test.go index 57af166..09e255c 100644 --- a/tree_test.go +++ b/tree_test.go @@ -1,11 +1,9 @@ package git import ( - "os" "sort" "gopkg.in/src-d/go-git.v3/core" - "gopkg.in/src-d/go-git.v3/formats/packfile" . "gopkg.in/check.v1" ) @@ -18,10 +16,7 @@ var _ = Suite(&SuiteTree{}) // create the repositories of the fixtures func (s *SuiteTree) SetUpSuite(c *C) { - fixtureRepos := [...]struct { - url string - packfile string - }{ + treeFixtures := []packedFixture{ {"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"}, {"https://github.com/cpcs499/Final_Pres_P.git", "formats/packfile/fixtures/Final_Pres_P.ofs-delta"}, {"https://github.com/jamesob/desk.git", "formats/packfile/fixtures/jamesob-desk.pack"}, @@ -29,21 +24,7 @@ func (s *SuiteTree) SetUpSuite(c *C) { {"https://github.com/alcortesm/binary-relations.git", "formats/packfile/fixtures/alcortesm-binary-relations.pack"}, {"https://github.com/Tribler/dispersy.git", "formats/packfile/fixtures/tribler-dispersy.pack"}, } - 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 // TODO: how to know the format of a pack file ahead of time? - - _, err = r.Read(s.repos[fixRepo.url].Storage) - c.Assert(err, IsNil) - - c.Assert(d.Close(), IsNil) - } + s.repos = unpackFixtures(c, treeFixtures) } func (s *SuiteTree) TestFile(c *C) { @@ -217,6 +198,8 @@ func (s *SuiteTree) TestFile(c *C) { } c.Assert(file.Size, Equals, t.size, comment) + c.Assert(file.Hash.IsZero(), Equals, false, comment) + c.Assert(file.Hash, Equals, file.ID(), comment) c.Assert(file.Hash.String(), Equals, t.blobHash, comment) } } |