@@ -15,8 +15,8 @@ type SuiteRepository struct {
1515
1616var _ = Suite (& SuiteRepository {})
1717
18- func (s * SuiteRepository ) SetUpTest (c * C ) {
19- s .repos = unpackFixtures (c , tagFixtures )
18+ func (s * SuiteRepository ) SetUpSuite (c * C ) {
19+ s .repos = unpackFixtures (c , tagFixtures , treeWalkerFixtures )
2020}
2121
2222func (s * SuiteRepository ) TestNewRepository (c * C ) {
@@ -58,6 +58,9 @@ func (s *SuiteRepository) TestCommit(c *C) {
5858 c .Assert (err , IsNil )
5959
6060 c .Assert (commit .Hash .IsZero (), Equals , false )
61+ c .Assert (commit .Hash , Equals , commit .ID ())
62+ c .Assert (commit .Hash , Equals , hash )
63+ c .Assert (commit .Type (), Equals , core .CommitObject )
6164 c .Assert (commit .Tree ().Hash .IsZero (), Equals , false )
6265 c .
Assert (
commit .
Author .
Email ,
Equals ,
"[email protected] " )
6366}
@@ -79,6 +82,8 @@ func (s *SuiteRepository) TestCommits(c *C) {
7982
8083 count ++
8184 c .Assert (commit .Hash .IsZero (), Equals , false )
85+ c .Assert (commit .Hash , Equals , commit .ID ())
86+ c .Assert (commit .Type (), Equals , core .CommitObject )
8287 //c.Assert(commit.Tree.IsZero(), Equals, false)
8388 }
8489
@@ -90,10 +95,11 @@ func (s *SuiteRepository) TestTag(c *C) {
9095 r , ok := s .repos [t .repo ]
9196 c .Assert (ok , Equals , true )
9297 k := 0
93- for hash , expected := range t .tags {
94- tag , err := r .Tag (core .NewHash (hash ))
98+ for hashString , expected := range t .tags {
99+ hash := core .NewHash (hashString )
100+ tag , err := r .Tag (hash )
95101 c .Assert (err , IsNil )
96- testTagExpected (c , tag , expected , fmt .Sprintf ("subtest %d, tag %d: " , i , k ))
102+ testTagExpected (c , tag , hash , expected , fmt .Sprintf ("subtest %d, tag %d: " , i , k ))
97103 k ++
98104 }
99105 }
@@ -107,6 +113,22 @@ func (s *SuiteRepository) TestTags(c *C) {
107113 }
108114}
109115
116+ func (s * SuiteRepository ) TestObject (c * C ) {
117+ for i , t := range treeWalkerTests {
118+ r , ok := s .repos [t .repo ]
119+ c .Assert (ok , Equals , true )
120+ for k := 0 ; k < len (t .objs ); k ++ {
121+ comment := fmt .Sprintf ("subtest %d, tag %d" , i , k )
122+ info := t .objs [k ]
123+ hash := core .NewHash (info .Hash )
124+ obj , err := r .Object (hash )
125+ c .Assert (err , IsNil , Commentf (comment ))
126+ c .Assert (obj .Type (), Equals , info .Kind , Commentf (comment ))
127+ c .Assert (obj .ID (), Equals , hash , Commentf (comment ))
128+ }
129+ }
130+ }
131+
110132func (s * SuiteRepository ) TestCommitIterClosePanic (c * C ) {
111133 r , err := NewRepository (RepositoryFixture , nil )
112134 r .Remotes ["origin" ].upSrv = & MockGitUploadPackService {}
0 commit comments