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

Method TestLogAllLimitForEach

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

Source from the content-addressed store, hash-verified

2330}
2331
2332func (s *RepositorySuite) TestLogAllLimitForEach(c *C) {
2333 r, _ := Init(memory.NewStorage(), nil)
2334 err := r.clone(context.Background(), &CloneOptions{
2335 URL: s.GetBasicLocalRepositoryURL(),
2336 })
2337
2338 c.Assert(err, IsNil)
2339
2340 since := time.Date(2015, 3, 31, 11, 54, 0, 0, time.UTC)
2341 until := time.Date(2015, 4, 1, 0, 0, 0, 0, time.UTC)
2342 cIter, err := r.Log(&LogOptions{Since: &since, Until: &until, All: true})
2343 c.Assert(err, IsNil)
2344 defer cIter.Close()
2345
2346 commitOrder := []plumbing.Hash{
2347 plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881"),
2348 plumbing.NewHash("918c48b83bd081e863dbe1b80f8998f058cd8294"),
2349 }
2350
2351 expectedIndex := 0
2352 err = cIter.ForEach(func(commit *object.Commit) error {
2353 expectedCommitHash := commitOrder[expectedIndex]
2354 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2355 expectedIndex++
2356 return nil
2357 })
2358 c.Assert(err, IsNil)
2359 c.Assert(expectedIndex, Equals, 2)
2360}
2361
2362func (s *RepositorySuite) TestLogLimitWithOtherParamsFail(c *C) {
2363 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