diff options
author | knqyf263 <knqyf263@gmail.com> | 2019-08-03 23:08:52 -1000 |
---|---|---|
committer | knqyf263 <knqyf263@gmail.com> | 2019-08-03 23:24:33 -1000 |
commit | d1f089794aff17a78d5487d5e681d63fba17aad1 (patch) | |
tree | 7c16c95f51f42e3265e38044164e603489dc8ca9 /repository_test.go | |
parent | d7c00b034ff5ce038c168ab16a943cc5f55aac3c (diff) | |
download | go-git-d1f089794aff17a78d5487d5e681d63fba17aad1.tar.gz |
Add TestLogFileWithError for coverage
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/repository_test.go b/repository_test.go index 0e46ded..5fc6aeb 100644 --- a/repository_test.go +++ b/repository_test.go @@ -3,6 +3,7 @@ package git import ( "bytes" "context" + "errors" "fmt" "io" "io/ioutil" @@ -13,7 +14,6 @@ import ( "testing" "time" - "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" openpgperr "golang.org/x/crypto/openpgp/errors" @@ -1653,6 +1653,28 @@ func (s *RepositorySuite) TestLogFileWithOtherParamsPass(c *C) { c.Assert(iterErr, Equals, io.EOF) } +type mockErrCommitIter struct{} + +func (m *mockErrCommitIter) Next() (*object.Commit, error) { + return nil, errors.New("mock next error") +} +func (m *mockErrCommitIter) ForEach(func(*object.Commit) error) error { + return errors.New("mock foreach error") +} + +func (m *mockErrCommitIter) Close() {} + +func (s *RepositorySuite) TestLogFileWithError(c *C) { + fileName := "README" + cIter := object.NewCommitFileIterFromIter(fileName, &mockErrCommitIter{}, false) + defer cIter.Close() + + err := cIter.ForEach(func(commit *object.Commit) error { + return nil + }) + c.Assert(err, NotNil) +} + func (s *RepositorySuite) TestCommit(c *C) { r, _ := Init(memory.NewStorage(), nil) err := r.clone(context.Background(), &CloneOptions{ |