@@ -2,6 +2,7 @@ package git
2
2
3
3
import (
4
4
"os"
5
+ "sort"
5
6
6
7
"gopkg.in/src-d/go-git.v2/core"
7
8
"gopkg.in/src-d/go-git.v2/formats/packfile"
@@ -26,6 +27,7 @@ func (s *SuiteTree) SetUpSuite(c *C) {
26
27
{"https://github.com/jamesob/desk.git" , "formats/packfile/fixtures/jamesob-desk.pack" },
27
28
{"https://github.com/spinnaker/spinnaker.git" , "formats/packfile/fixtures/spinnaker-spinnaker.pack" },
28
29
{"https://github.com/alcortesm/binary-relations.git" , "formats/packfile/fixtures/alcortesm-binary-relations.pack" },
30
+ {"https://github.com/Tribler/dispersy.git" , "formats/packfile/fixtures/tribler-dispersy.pack" },
29
31
}
30
32
s .repos = make (map [string ]* Repository , 0 )
31
33
for _ , fixRepo := range fixtureRepos {
@@ -132,3 +134,69 @@ func (s *SuiteTree) TestFile(c *C) {
132
134
}
133
135
}
134
136
}
137
+
138
+ func (s * SuiteTree ) TestFiles (c * C ) {
139
+ for i , t := range []struct {
140
+ repo string // the repo name as in localRepos
141
+ commit string // the commit to search for the file
142
+ files []string // the expected files in the commit
143
+ }{
144
+ {"https://github.com/alcortesm/binary-relations.git" , "b373f85fa2594d7dcd9989f4a5858a81647fb8ea" , []string {
145
+ "binary-relations.tex" ,
146
+ ".gitignore" ,
147
+ "imgs-gen/simple-graph/fig.fig" ,
148
+ "imgs-gen/simple-graph/Makefile" ,
149
+ "Makefile" ,
150
+ "src/map-slice/map-slice.go" ,
151
+ "src/simple-arrays/simple-arrays.go" ,
152
+ }},
153
+ {"https://github.com/Tribler/dispersy.git" , "f5a1fca709f760bf75a7adaa480bf0f0e1a547ee" , []string {
154
+ "authentication.py" ,
155
+ "bloomfilter.py" ,
156
+ "bootstrap.py" ,
157
+ "cache.py" ,
158
+ "callback.py" ,
159
+ "candidate.py" ,
160
+ "community.py" ,
161
+ "conversion.py" ,
162
+ "crypto.py" ,
163
+ "database.py" ,
164
+ "debugcommunity.py" ,
165
+ "debug.py" ,
166
+ "decorator.py" ,
167
+ "destination.py" ,
168
+ "dispersydatabase.py" ,
169
+ "dispersy.py" ,
170
+ "distribution.py" ,
171
+ "dprint.py" ,
172
+ "encoding.py" ,
173
+ "endpoint.py" ,
174
+ "__init__.py" ,
175
+ "member.py" ,
176
+ "message.py" ,
177
+ "meta.py" ,
178
+ "payload.py" ,
179
+ "requestcache.py" ,
180
+ "resolution.py" ,
181
+ "script.py" ,
182
+ "singleton.py" ,
183
+ "timeline.py" ,
184
+ "tool/callbackscript.py" ,
185
+ "tool/__init__.py" ,
186
+ "tool/scenarioscript.py" ,
187
+ }},
188
+ {"https://github.com/Tribler/dispersy.git" , "9d38ff85ca03adcf68dc14f5b68b8994f15229f4" , []string (nil )},
189
+ } {
190
+ commit , err := s .repos [t .repo ].Commit (core .NewHash (t .commit ))
191
+ c .Assert (err , IsNil , Commentf ("subtest %d: %v (%s)" , i , err , t .commit ))
192
+
193
+ tree := commit .Tree ()
194
+ var output []string
195
+ for file := range tree .Files () {
196
+ output = append (output , file .Name )
197
+ }
198
+ sort .Strings (output )
199
+ sort .Strings (t .files )
200
+ c .Assert (output , DeepEquals , t .files , Commentf ("subtest %d, repo=%s, commit=%s" , i , t .repo , t .commit ))
201
+ }
202
+ }
0 commit comments