MCPcopy
hub / github.com/go-git/go-git / TestLogAllFileForEach

Method TestLogAllFileForEach

repository_test.go:2041–2067  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

2039}
2040
2041func (s *RepositorySuite) TestLogAllFileForEach(c *C) {
2042 r, _ := Init(memory.NewStorage(), nil)
2043 err := r.clone(context.Background(), &CloneOptions{
2044 URL: s.GetBasicLocalRepositoryURL(),
2045 })
2046
2047 c.Assert(err, IsNil)
2048
2049 fileName := "README"
2050 cIter, err := r.Log(&LogOptions{FileName: &fileName, All: true})
2051 c.Assert(err, IsNil)
2052 defer cIter.Close()
2053
2054 commitOrder := []plumbing.Hash{
2055 plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881"),
2056 }
2057
2058 expectedIndex := 0
2059 err = cIter.ForEach(func(commit *object.Commit) error {
2060 expectedCommitHash := commitOrder[expectedIndex]
2061 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2062 expectedIndex++
2063 return nil
2064 })
2065 c.Assert(err, IsNil)
2066 c.Assert(expectedIndex, Equals, 1)
2067}
2068
2069func (s *RepositorySuite) TestLogInvalidFile(c *C) {
2070 r, _ := Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
NewHashFunction · 0.92
InitFunction · 0.85
cloneMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
ForEachMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected