Skip to content

Commit

Permalink
Merge pull request #1077 from onee-only/refine-tests
Browse files Browse the repository at this point in the history
git: Refine some codes in test and non-test.
  • Loading branch information
pjbgf committed Apr 11, 2024
2 parents cd6633c + 63a48ce commit 7d39843
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
5 changes: 1 addition & 4 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions plumbing/serverinfo/serverinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions worktree_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions worktree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 7d39843

Please sign in to comment.