Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit d1f0897

Browse files
committed
Add TestLogFileWithError for coverage
Signed-off-by: knqyf263 <knqyf263@gmail.com>
1 parent d7c00b0 commit d1f0897

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎repository_test.go‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package git
33
import (
44
"bytes"
55
"context"
6+
"errors"
67
"fmt"
78
"io"
89
"io/ioutil"
@@ -13,7 +14,6 @@ import (
1314
"testing"
1415
"time"
1516

16-
1717
"golang.org/x/crypto/openpgp"
1818
"golang.org/x/crypto/openpgp/armor"
1919
openpgperr "golang.org/x/crypto/openpgp/errors"
@@ -1653,6 +1653,28 @@ func (s *RepositorySuite) TestLogFileWithOtherParamsPass(c *C) {
16531653
c.Assert(iterErr, Equals, io.EOF)
16541654
}
16551655

1656+
type mockErrCommitIter struct{}
1657+
1658+
func (m *mockErrCommitIter) Next() (*object.Commit, error) {
1659+
return nil, errors.New("mock next error")
1660+
}
1661+
func (m *mockErrCommitIter) ForEach(func(*object.Commit) error) error {
1662+
return errors.New("mock foreach error")
1663+
}
1664+
1665+
func (m *mockErrCommitIter) Close() {}
1666+
1667+
func (s *RepositorySuite) TestLogFileWithError(c *C) {
1668+
fileName := "README"
1669+
cIter := object.NewCommitFileIterFromIter(fileName, &mockErrCommitIter{}, false)
1670+
defer cIter.Close()
1671+
1672+
err := cIter.ForEach(func(commit *object.Commit) error {
1673+
return nil
1674+
})
1675+
c.Assert(err, NotNil)
1676+
}
1677+
16561678
func (s *RepositorySuite) TestCommit(c *C) {
16571679
r, _ := Init(memory.NewStorage(), nil)
16581680
err := r.clone(context.Background(), &CloneOptions{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /