aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2019-07-21 06:05:19 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2019-07-29 17:32:34 +0200
commit172a0d8a0e1e05d0bc47df09d50fb8ef49529f5f (patch)
tree91d8f762673d2dd5ced806c0d59197db62494a83
parentaf46dd50e9e0bea569449c4a70fc9217594cb2ba (diff)
downloadgo-git-172a0d8a0e1e05d0bc47df09d50fb8ef49529f5f.tar.gz
*: 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> (cherry picked from commit 19d6f42a4d814a50bd262fbb69a9b670db9756a2)
-rw-r--r--plumbing/format/packfile/scanner_test.go1
-rw-r--r--plumbing/object/patch_test.go1
-rw-r--r--prune_test.go2
-rw-r--r--repository_test.go4
-rw-r--r--storage/filesystem/dotgit/dotgit_test.go1
-rw-r--r--worktree_commit_test.go2
-rw-r--r--worktree_test.go1
7 files changed, 10 insertions, 2 deletions
diff --git a/plumbing/format/packfile/scanner_test.go b/plumbing/format/packfile/scanner_test.go
index a401d6d..3078477 100644
--- a/plumbing/format/packfile/scanner_test.go
+++ b/plumbing/format/packfile/scanner_test.go
@@ -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))
diff --git a/plumbing/object/patch_test.go b/plumbing/object/patch_test.go
index 47057fb..37944c3 100644
--- a/plumbing/object/patch_test.go
+++ b/plumbing/object/patch_test.go
@@ -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)
diff --git a/prune_test.go b/prune_test.go
index 670cd07..2279636 100644
--- a/prune_test.go
+++ b/prune_test.go
@@ -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 {
diff --git a/repository_test.go b/repository_test.go
index 32fa4fa..b87eabb 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -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))
}
diff --git a/storage/filesystem/dotgit/dotgit_test.go b/storage/filesystem/dotgit/dotgit_test.go
index 73b0291..31c6fe0 100644
--- a/storage/filesystem/dotgit/dotgit_test.go
+++ b/storage/filesystem/dotgit/dotgit_test.go
@@ -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()
diff --git a/worktree_commit_test.go b/worktree_commit_test.go
index da377c6..5bcbac9 100644
--- a/worktree_commit_test.go
+++ b/worktree_commit_test.go
@@ -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,
})
diff --git a/worktree_test.go b/worktree_test.go
index 045a76d..1f87957 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -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{})