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

Commit 19d6f42

Browse files
committed
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 <muesli@gmail.com>
1 parent c363771 commit 19d6f42

File tree

7 files changed

+10
-2
lines changed

7 files changed

+10
-2
lines changed

plumbing/format/packfile/scanner_test.go

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,14 @@ func (s *RepositorySuite) TestCreateBranchUnmarshal(c *C) {
335335
Merge: "refs/heads/foo",
336336
}
337337
err = r.CreateBranch(testBranch1)
338+
c.Assert(err, IsNil)
338339
err = r.CreateBranch(testBranch2)
339-
340340
c.Assert(err, IsNil)
341+
341342
cfg, err := r.Config()
342343
c.Assert(err, IsNil)
343344
marshaled, err := cfg.Marshal()
345+
c.Assert(err, IsNil)
344346
c.Assert(string(expected), Equals, string(marshaled))
345347
}
346348

storage/filesystem/dotgit/dotgit_test.go

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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)