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

Commit 172a0d8

Browse files
mueslimcuadros
authored andcommitted
*: added missing error checks in tests
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 <[email protected]> (cherry picked from commit 19d6f42)
1 parent af46dd5 commit 172a0d8

File tree

7 files changed

+10
-2
lines changed

7 files changed

+10
-2
lines changed

plumbing/format/packfile/scanner_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func (s *ScannerSuite) TestReaderReset(c *C) {
140140
p := NewScanner(r)
141141

142142
version, objects, err := p.Header()
143+
c.Assert(err, IsNil)
143144
c.Assert(version, Equals, VersionSupported)
144145
c.Assert(objects, Equals, uint32(31))
145146

plumbing/object/patch_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func (s *PatchSuite) TestStatsWithSubmodules(c *C) {
1919
fixtures.ByURL("https://github.com/git-fixtures/submodule.git").One().DotGit(), cache.NewObjectLRUDefault())
2020

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

2324
tree, err := commit.Tree()
2425
c.Assert(err, IsNil)

prune_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func (s *PruneSuite) testPrune(c *C, deleteTime time.Time) {
5656
newCount++
5757
return nil
5858
})
59+
c.Assert(err, IsNil)
60+
5961
if deleteTime.IsZero() {
6062
c.Assert(newCount < count, Equals, true)
6163
} else {

repository_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,14 @@ func (s *RepositorySuite) TestCreateBranchUnmarshal(c *C) {
336336
Merge: "refs/heads/foo",
337337
}
338338
err = r.CreateBranch(testBranch1)
339+
c.Assert(err, IsNil)
339340
err = r.CreateBranch(testBranch2)
340-
341341
c.Assert(err, IsNil)
342+
342343
cfg, err := r.Config()
343344
c.Assert(err, IsNil)
344345
marshaled, err := cfg.Marshal()
346+
c.Assert(err, IsNil)
345347
c.Assert(string(expected), Equals, string(marshaled))
346348
}
347349

storage/filesystem/dotgit/dotgit_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func (s *SuiteDotGit) TestRemoveRefFromReferenceFileAndPackedRefs(c *C) {
226226
"refs/remotes/origin/branch",
227227
"e8d3ffab552895c19b9fcf7aa264d277cde33881",
228228
), nil)
229+
c.Assert(err, IsNil)
229230

230231
// Make sure it only appears once in the refs list.
231232
refs, err := dir.Refs()

worktree_commit_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (s *WorktreeSuite) TestCommitTreeSort(c *C) {
210210
r, err := Init(st, nil)
211211
c.Assert(err, IsNil)
212212

213-
r, err = Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
213+
r, _ = Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
214214
URL: path,
215215
})
216216

worktree_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ func (s *WorktreeSuite) TestClean(c *C) {
16751675

16761676
// Status before cleaning.
16771677
status, err := wt.Status()
1678+
c.Assert(err, IsNil)
16781679
c.Assert(len(status), Equals, 2)
16791680

16801681
err = wt.Clean(&CleanOptions{})

0 commit comments

Comments
 (0)