Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
*: added missing error checks in tests
Browse files Browse the repository at this point in the history
When we assign a value to err, make sure to also check for it being nil
afterwards. If those were intentionally unchecked, we should remove the
assignment in the first place. Those checks certainly never harm, but please
review thoroughly and let me know.

Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com>
(cherry picked from commit 19d6f42)
  • Loading branch information
muesli authored and mcuadros committed Jul 29, 2019
1 parent af46dd5 commit 172a0d8
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions plumbing/format/packfile/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (s *ScannerSuite) TestReaderReset(c *C) {
p := NewScanner(r)

version, objects, err := p.Header()
c.Assert(err, IsNil)
c.Assert(version, Equals, VersionSupported)
c.Assert(objects, Equals, uint32(31))

Expand Down
1 change: 1 addition & 0 deletions plumbing/object/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (s *PatchSuite) TestStatsWithSubmodules(c *C) {
fixtures.ByURL("https://github.com/git-fixtures/submodule.git").One().DotGit(), cache.NewObjectLRUDefault())

commit, err := GetCommit(storer, plumbing.NewHash("b685400c1f9316f350965a5993d350bc746b0bf4"))
c.Assert(err, IsNil)

tree, err := commit.Tree()
c.Assert(err, IsNil)
Expand Down
2 changes: 2 additions & 0 deletions prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (s *PruneSuite) testPrune(c *C, deleteTime time.Time) {
newCount++
return nil
})
c.Assert(err, IsNil)

if deleteTime.IsZero() {
c.Assert(newCount < count, Equals, true)
} else {
Expand Down
4 changes: 3 additions & 1 deletion repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ func (s *RepositorySuite) TestCreateBranchUnmarshal(c *C) {
Merge: "refs/heads/foo",
}
err = r.CreateBranch(testBranch1)
c.Assert(err, IsNil)
err = r.CreateBranch(testBranch2)

c.Assert(err, IsNil)

cfg, err := r.Config()
c.Assert(err, IsNil)
marshaled, err := cfg.Marshal()
c.Assert(err, IsNil)
c.Assert(string(expected), Equals, string(marshaled))
}

Expand Down
1 change: 1 addition & 0 deletions storage/filesystem/dotgit/dotgit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (s *SuiteDotGit) TestRemoveRefFromReferenceFileAndPackedRefs(c *C) {
"refs/remotes/origin/branch",
"e8d3ffab552895c19b9fcf7aa264d277cde33881",
), nil)
c.Assert(err, IsNil)

// Make sure it only appears once in the refs list.
refs, err := dir.Refs()
Expand Down
2 changes: 1 addition & 1 deletion worktree_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (s *WorktreeSuite) TestCommitTreeSort(c *C) {
r, err := Init(st, nil)
c.Assert(err, IsNil)

r, err = Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
r, _ = Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
URL: path,
})

Expand Down
1 change: 1 addition & 0 deletions worktree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@ func (s *WorktreeSuite) TestClean(c *C) {

// Status before cleaning.
status, err := wt.Status()
c.Assert(err, IsNil)
c.Assert(len(status), Equals, 2)

err = wt.Clean(&CleanOptions{})
Expand Down

0 comments on commit 172a0d8

Please sign in to comment.