diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-04-11 17:29:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 17:29:47 +0100 |
commit | 7d3984315fa46391f174f291b81d2ce2fd7d4ed4 (patch) | |
tree | 0d94fd84dbe7ed401b19faac39d19b813ed49dec | |
parent | cd6633c3c665ba37f766e96c59c57c58051d0e58 (diff) | |
parent | 63a48ce846d316f8689e367e884069944c0e4831 (diff) | |
download | go-git-7d3984315fa46391f174f291b81d2ce2fd7d4ed4.tar.gz |
Merge pull request #1077 from onee-only/refine-tests
git: Refine some codes in test and non-test.
-rw-r--r-- | blame.go | 5 | ||||
-rw-r--r-- | plumbing/serverinfo/serverinfo_test.go | 1 | ||||
-rw-r--r-- | remote_test.go | 2 | ||||
-rw-r--r-- | worktree_commit_test.go | 4 | ||||
-rw-r--r-- | worktree_test.go | 6 |
5 files changed, 11 insertions, 7 deletions
@@ -97,13 +97,10 @@ func Blame(c *object.Commit, path string) (*BlameResult, error) { if err != nil { return nil, err } - if finished == true { + if finished { break } } - if err != nil { - return nil, err - } b.lineToCommit = make([]*object.Commit, finalLength) for i := range needsMap { diff --git a/plumbing/serverinfo/serverinfo_test.go b/plumbing/serverinfo/serverinfo_test.go index 0a52ea2..251746b 100644 --- a/plumbing/serverinfo/serverinfo_test.go +++ b/plumbing/serverinfo/serverinfo_test.go @@ -179,6 +179,7 @@ func (s *ServerInfoSuite) TestUpdateServerInfoBasicChange(c *C) { c.Assert(err, IsNil) err = UpdateServerInfo(st, fs) + c.Assert(err, IsNil) assertInfoRefs(c, st, fs) assertObjectPacks(c, st, fs) diff --git a/remote_test.go b/remote_test.go index 1ffedd4..d1439d5 100644 --- a/remote_test.go +++ b/remote_test.go @@ -1489,6 +1489,7 @@ func (s *RemoteSuite) TestFetchPrune(c *C) { err = remote.Push(&PushOptions{RefSpecs: []config.RefSpec{ ":refs/heads/branch", }}) + c.Assert(err, IsNil) AssertReferences(c, rSave, map[string]string{ "refs/remotes/origin/branch": ref.Hash().String(), @@ -1546,6 +1547,7 @@ func (s *RemoteSuite) TestFetchPruneTags(c *C) { err = remote.Push(&PushOptions{RefSpecs: []config.RefSpec{ ":refs/tags/v1", }}) + c.Assert(err, IsNil) AssertReferences(c, rSave, map[string]string{ "refs/tags/v1": ref.Hash().String(), diff --git a/worktree_commit_test.go b/worktree_commit_test.go index fee8b15..ae8f841 100644 --- a/worktree_commit_test.go +++ b/worktree_commit_test.go @@ -233,7 +233,9 @@ func (s *WorktreeSuite) TestAddAndCommitWithSkipStatusPathNotModified(c *C) { }) c.Assert(hash, Equals, expected) c.Assert(err, IsNil) + commit1, err := w.r.CommitObject(hash) + c.Assert(err, IsNil) status, err = w.Status() c.Assert(err, IsNil) @@ -260,7 +262,9 @@ func (s *WorktreeSuite) TestAddAndCommitWithSkipStatusPathNotModified(c *C) { }) c.Assert(hash, Equals, expected2) c.Assert(err, IsNil) + commit2, err := w.r.CommitObject(hash) + c.Assert(err, IsNil) status, err = w.Status() c.Assert(err, IsNil) diff --git a/worktree_test.go b/worktree_test.go index 668c30a..f67cca2 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "errors" - "fmt" "io" "os" "path/filepath" @@ -1241,6 +1240,7 @@ func (s *WorktreeSuite) TestResetHardWithGitIgnore(c *C) { f, err := fs.Create(".gitignore") c.Assert(err, IsNil) _, err = f.Write([]byte("foo\n")) + c.Assert(err, IsNil) _, err = f.Write([]byte("newTestFile.txt\n")) c.Assert(err, IsNil) err = f.Close() @@ -2982,7 +2982,7 @@ func TestValidPath(t *testing.T) { } for _, tc := range tests { - t.Run(fmt.Sprintf("%s", tc.path), func(t *testing.T) { + t.Run(tc.path, func(t *testing.T) { err := validPath(tc.path) if tc.wantErr { assert.Error(t, err) @@ -3013,7 +3013,7 @@ func TestWindowsValidPath(t *testing.T) { } for _, tc := range tests { - t.Run(fmt.Sprintf("%s", tc.path), func(t *testing.T) { + t.Run(tc.path, func(t *testing.T) { got := windowsValidPath(tc.path) assert.Equal(t, tc.want, got) }) |