MCPcopy Index your code
hub / github.com/go-git/go-git / TestFileIter

Method TestFileIter

plumbing/object/file_test.go:214–247  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

212}
213
214func (s *FileSuite) TestFileIter(c *C) {
215 hash := plumbing.NewHash("1669dce138d9b841a518c64b10914d88f5e488ea")
216 commit, err := GetCommit(s.Storer, hash)
217 c.Assert(err, IsNil)
218
219 tree, err := commit.Tree()
220 c.Assert(err, IsNil)
221
222 expected := []string{
223 ".gitignore",
224 "CHANGELOG",
225 "LICENSE",
226 "binary.jpg",
227 }
228
229 var count int
230 i := tree.Files()
231 i.ForEach(func(f *File) error {
232 c.Assert(f.Name, Equals, expected[count])
233 count++
234 return nil
235 })
236
237 c.Assert(count, Equals, 4)
238
239 count = 0
240 i = tree.Files()
241 i.ForEach(func(f *File) error {
242 count++
243 return storer.ErrStop
244 })
245
246 c.Assert(count, Equals, 1)
247}
248
249func (s *FileSuite) TestFileIterSubmodule(c *C) {
250 dotgit := fixtures.ByURL("https://github.com/git-fixtures/submodule.git").One().DotGit()

Callers

nothing calls this directly

Calls 5

NewHashFunction · 0.92
GetCommitFunction · 0.85
TreeMethod · 0.65
FilesMethod · 0.65
ForEachMethod · 0.65

Tested by

no test coverage detected