MCPcopy Create free account
hub / github.com/go-git/go-git / TestLogAllFileForEach

Method TestLogAllFileForEach

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

Source from the content-addressed store, hash-verified

2071}
2072
2073func (s *RepositorySuite) TestLogAllFileForEach(c *C) {
2074 r, _ := Init(memory.NewStorage(), nil)
2075 err := r.clone(context.Background(), &CloneOptions{
2076 URL: s.GetBasicLocalRepositoryURL(),
2077 })
2078
2079 c.Assert(err, IsNil)
2080
2081 fileName := "README"
2082 cIter, err := r.Log(&LogOptions{FileName: &fileName, All: true})
2083 c.Assert(err, IsNil)
2084 defer cIter.Close()
2085
2086 commitOrder := []plumbing.Hash{
2087 plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881"),
2088 }
2089
2090 expectedIndex := 0
2091 err = cIter.ForEach(func(commit *object.Commit) error {
2092 expectedCommitHash := commitOrder[expectedIndex]
2093 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2094 expectedIndex++
2095 return nil
2096 })
2097 c.Assert(err, IsNil)
2098 c.Assert(expectedIndex, Equals, 1)
2099}
2100
2101func (s *RepositorySuite) TestLogInvalidFile(c *C) {
2102 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