Skip to content

Commit 5e4e7d3

Browse files
mueslizeripath
authored andcommitted
Added missing error checks in tests (#7554)
Whenever we assign a value to err, check for it being nil.
1 parent 54d96c7 commit 5e4e7d3

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

models/release_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func TestRelease_MirrorDelete(t *testing.T) {
139139
assert.True(t, ok)
140140

141141
count, err := GetReleaseCountByRepoID(mirror.ID, findOptions)
142+
assert.NoError(t, err)
142143
assert.EqualValues(t, initCount+1, count)
143144

144145
release, err := GetRelease(repo.ID, "v0.2")
@@ -149,5 +150,6 @@ func TestRelease_MirrorDelete(t *testing.T) {
149150
assert.True(t, ok)
150151

151152
count, err = GetReleaseCountByRepoID(mirror.ID, findOptions)
153+
assert.NoError(t, err)
152154
assert.EqualValues(t, initCount, count)
153155
}

models/repo_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
8888

8989
// Get sample repo and change visibility
9090
repo, err := GetRepositoryByID(9)
91+
assert.NoError(t, err)
9192
repo.IsPrivate = true
9293

9394
// Update it

modules/git/repo_commit_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ func TestRepository_GetCommitBranches(t *testing.T) {
4040
func TestGetTagCommitWithSignature(t *testing.T) {
4141
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
4242
bareRepo1, err := OpenRepository(bareRepo1Path)
43-
commit, err := bareRepo1.GetCommit("3ad28a9149a2864384548f3d17ed7f38014c9e8a")
43+
assert.NoError(t, err)
4444

45+
commit, err := bareRepo1.GetCommit("3ad28a9149a2864384548f3d17ed7f38014c9e8a")
4546
assert.NoError(t, err)
4647
assert.NotNil(t, commit)
4748
assert.NotNil(t, commit.Signature)
@@ -52,6 +53,8 @@ func TestGetTagCommitWithSignature(t *testing.T) {
5253
func TestGetCommitWithBadCommitID(t *testing.T) {
5354
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
5455
bareRepo1, err := OpenRepository(bareRepo1Path)
56+
assert.NoError(t, err)
57+
5558
commit, err := bareRepo1.GetCommit("bad_branch")
5659
assert.Nil(t, commit)
5760
assert.Error(t, err)

modules/git/repo_stats_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestRepository_GetCodeActivityStats(t *testing.T) {
1818
assert.NoError(t, err)
1919

2020
timeFrom, err := time.Parse(time.RFC3339, "2016-01-01T00:00:00+00:00")
21+
assert.NoError(t, err)
2122

2223
code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
2324
assert.NoError(t, err)

0 commit comments

Comments
 (0)