aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorStephen Solka <solka@hey.com>2020-07-19 05:53:40 -0400
committerGitHub <noreply@github.com>2020-07-19 12:53:40 +0300
commit54513452a1134de670467e5a8d5cebd768b3c7e4 (patch)
tree48e39d2e52daa88cf93431dd6b0642e482a5e018 /modules/repofiles
parentb609a25014cf732ec444c132dc9fb892818281dc (diff)
downloadgitea-54513452a1134de670467e5a8d5cebd768b3c7e4.tar.gz
gitea-54513452a1134de670467e5a8d5cebd768b3c7e4.zip
prefer NoError/Error over Nil/NotNil (#12271)
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/blob_test.go2
-rw-r--r--modules/repofiles/content_test.go12
-rw-r--r--modules/repofiles/diff_test.go4
-rw-r--r--modules/repofiles/file_test.go2
-rw-r--r--modules/repofiles/tree_test.go2
5 files changed, 11 insertions, 11 deletions
diff --git a/modules/repofiles/blob_test.go b/modules/repofiles/blob_test.go
index ddc23aeac3..8ba80347bf 100644
--- a/modules/repofiles/blob_test.go
+++ b/modules/repofiles/blob_test.go
@@ -35,6 +35,6 @@ func TestGetBlobBySHA(t *testing.T) {
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
Size: 180,
}
- assert.Nil(t, err)
+ assert.NoError(t, err)
assert.Equal(t, expectedGBR, gbr)
}
diff --git a/modules/repofiles/content_test.go b/modules/repofiles/content_test.go
index d024cfd549..2782161122 100644
--- a/modules/repofiles/content_test.go
+++ b/modules/repofiles/content_test.go
@@ -66,13 +66,13 @@ func TestGetContents(t *testing.T) {
t.Run("Get README.md contents with GetContents()", func(t *testing.T) {
fileContentResponse, err := GetContents(ctx.Repo.Repository, treePath, ref, false)
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
t.Run("Get REAMDE.md contents with ref as empty string (should then use the repo's default branch) with GetContents()", func(t *testing.T) {
fileContentResponse, err := GetContents(ctx.Repo.Repository, treePath, "", false)
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
}
@@ -101,13 +101,13 @@ func TestGetContentsOrListForDir(t *testing.T) {
t.Run("Get root dir contents with GetContentsOrList()", func(t *testing.T) {
fileContentResponse, err := GetContentsOrList(ctx.Repo.Repository, treePath, ref)
assert.EqualValues(t, expectedContentsListResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
t.Run("Get root dir contents with ref as empty string (should then use the repo's default branch) with GetContentsOrList()", func(t *testing.T) {
fileContentResponse, err := GetContentsOrList(ctx.Repo.Repository, treePath, "")
assert.EqualValues(t, expectedContentsListResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
}
@@ -129,13 +129,13 @@ func TestGetContentsOrListForFile(t *testing.T) {
t.Run("Get README.md contents with GetContentsOrList()", func(t *testing.T) {
fileContentResponse, err := GetContentsOrList(ctx.Repo.Repository, treePath, ref)
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
t.Run("Get REAMDE.md contents with ref as empty string (should then use the repo's default branch) with GetContentsOrList()", func(t *testing.T) {
fileContentResponse, err := GetContentsOrList(ctx.Repo.Repository, treePath, "")
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
- assert.Nil(t, err)
+ assert.NoError(t, err)
})
}
diff --git a/modules/repofiles/diff_test.go b/modules/repofiles/diff_test.go
index d9e144be82..d40f8a50fe 100644
--- a/modules/repofiles/diff_test.go
+++ b/modules/repofiles/diff_test.go
@@ -113,13 +113,13 @@ func TestGetDiffPreview(t *testing.T) {
t.Run("with given branch", func(t *testing.T) {
diff, err := GetDiffPreview(ctx.Repo.Repository, branch, treePath, content)
- assert.Nil(t, err)
+ assert.NoError(t, err)
assert.EqualValues(t, expectedDiff, diff)
})
t.Run("empty branch, same results", func(t *testing.T) {
diff, err := GetDiffPreview(ctx.Repo.Repository, "", treePath, content)
- assert.Nil(t, err)
+ assert.NoError(t, err)
assert.EqualValues(t, expectedDiff, diff)
})
}
diff --git a/modules/repofiles/file_test.go b/modules/repofiles/file_test.go
index 3cb4eb472b..aafe816a16 100644
--- a/modules/repofiles/file_test.go
+++ b/modules/repofiles/file_test.go
@@ -99,6 +99,6 @@ func TestGetFileResponseFromCommit(t *testing.T) {
expectedFileResponse := getExpectedFileResponse()
fileResponse, err := GetFileResponseFromCommit(repo, commit, branch, treePath)
- assert.Nil(t, err)
+ assert.NoError(t, err)
assert.EqualValues(t, expectedFileResponse, fileResponse)
}
diff --git a/modules/repofiles/tree_test.go b/modules/repofiles/tree_test.go
index e1bb812ec1..274e89e969 100644
--- a/modules/repofiles/tree_test.go
+++ b/modules/repofiles/tree_test.go
@@ -30,7 +30,7 @@ func TestGetTreeBySHA(t *testing.T) {
ctx.SetParams(":sha", sha)
tree, err := GetTreeBySHA(ctx.Repo.Repository, ctx.Params(":sha"), page, perPage, true)
- assert.Nil(t, err)
+ assert.NoError(t, err)
expectedTree := &api.GitTreeResponse{
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/trees/65f1bf27bc3bf70f64657658635e66094edbcb4d",