mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Enable testifylint rules (#34075)
enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
This commit is contained in:
@@ -33,7 +33,7 @@ func TestArchive_Basic(t *testing.T) {
|
||||
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, firstCommit+".zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, firstCommit+".zip", bogusReq.GetArchiveName())
|
||||
|
||||
// Check a series of bogus requests.
|
||||
// Step 1, valid commit with a bad extension.
|
||||
@@ -54,12 +54,12 @@ func TestArchive_Basic(t *testing.T) {
|
||||
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "master.zip")
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, "master.zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, "master.zip", bogusReq.GetArchiveName())
|
||||
|
||||
bogusReq, err = NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "test/archive.zip")
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, "test-archive.zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, "test-archive.zip", bogusReq.GetArchiveName())
|
||||
|
||||
// Now two valid requests, firstCommit with valid extensions.
|
||||
zipReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
|
||||
|
@@ -59,7 +59,7 @@ func TestDeleteAvatar(t *testing.T) {
|
||||
err = DeleteAvatar(db.DefaultContext, repo)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "", repo.Avatar)
|
||||
assert.Empty(t, repo.Avatar)
|
||||
}
|
||||
|
||||
func TestGenerateAvatar(t *testing.T) {
|
||||
|
@@ -38,14 +38,14 @@ func TestRepository_ContributorsGraph(t *testing.T) {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
slices.Sort(keys)
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"ethantkoenig@gmail.com",
|
||||
"jimmy.praet@telenet.be",
|
||||
"jon@allspice.io",
|
||||
"total", // generated summary
|
||||
}, keys)
|
||||
|
||||
assert.EqualValues(t, &ContributorData{
|
||||
assert.Equal(t, &ContributorData{
|
||||
Name: "Ethan Koenig",
|
||||
AvatarLink: "/assets/img/avatar_default.png",
|
||||
TotalCommits: 1,
|
||||
@@ -58,7 +58,7 @@ func TestRepository_ContributorsGraph(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, data["ethantkoenig@gmail.com"])
|
||||
assert.EqualValues(t, &ContributorData{
|
||||
assert.Equal(t, &ContributorData{
|
||||
Name: "Total",
|
||||
AvatarLink: "",
|
||||
TotalCommits: 3,
|
||||
|
@@ -67,13 +67,13 @@ func TestGetContents(t *testing.T) {
|
||||
|
||||
t.Run("Get README.md contents with GetContents(ctx, )", func(t *testing.T) {
|
||||
fileContentResponse, err := GetContents(ctx, ctx.Repo.Repository, treePath, ref, false)
|
||||
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.Equal(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Get README.md contents with ref as empty string (should then use the repo's default branch) with GetContents(ctx, )", func(t *testing.T) {
|
||||
fileContentResponse, err := GetContents(ctx, ctx.Repo.Repository, treePath, "", false)
|
||||
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.Equal(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
@@ -118,7 +118,7 @@ func TestGetDiffPreview(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
bs, err := json.Marshal(diff)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, string(expectedBs), string(bs))
|
||||
assert.Equal(t, string(expectedBs), string(bs))
|
||||
})
|
||||
|
||||
t.Run("empty branch, same results", func(t *testing.T) {
|
||||
@@ -128,7 +128,7 @@ func TestGetDiffPreview(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
bs, err := json.Marshal(diff)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, expectedBs, bs)
|
||||
assert.Equal(t, expectedBs, bs)
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -20,14 +20,14 @@ func TestCleanUploadFileName(t *testing.T) {
|
||||
name := "this/is/test"
|
||||
cleanName := CleanUploadFileName(name)
|
||||
expectedCleanName := name
|
||||
assert.EqualValues(t, expectedCleanName, cleanName)
|
||||
assert.Equal(t, expectedCleanName, cleanName)
|
||||
})
|
||||
|
||||
t.Run("Clean a .git path", func(t *testing.T) {
|
||||
name := "this/is/test/.git"
|
||||
cleanName := CleanUploadFileName(name)
|
||||
expectedCleanName := ""
|
||||
assert.EqualValues(t, expectedCleanName, cleanName)
|
||||
assert.Equal(t, expectedCleanName, cleanName)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,5 +116,5 @@ func TestGetFileResponseFromCommit(t *testing.T) {
|
||||
|
||||
fileResponse, err := GetFileResponseFromCommit(ctx, repo, commit, branch, treePath)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, expectedFileResponse, fileResponse)
|
||||
assert.Equal(t, expectedFileResponse, fileResponse)
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ func TestGetTreeBySHA(t *testing.T) {
|
||||
TotalCount: 1,
|
||||
}
|
||||
|
||||
assert.EqualValues(t, expectedTree, tree)
|
||||
assert.Equal(t, expectedTree, tree)
|
||||
}
|
||||
|
||||
func TestGetTreeViewNodes(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user