diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-04-22 23:56:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 17:56:27 -0400 |
commit | f1173d6879cb26af21483037fae72542f3088408 (patch) | |
tree | a1ed73fb2a42c351005974698076f5ee82489d5d /services | |
parent | ac384c4e1d207a989d0f646ebc14fd0c26427d4c (diff) | |
download | gitea-f1173d6879cb26af21483037fae72542f3088408.tar.gz gitea-f1173d6879cb26af21483037fae72542f3088408.zip |
Use more specific test methods (#24265)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'services')
-rw-r--r-- | services/issue/assignee_test.go | 6 | ||||
-rw-r--r-- | services/issue/issue_test.go | 6 | ||||
-rw-r--r-- | services/repository/adopt_test.go | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/services/issue/assignee_test.go b/services/issue/assignee_test.go index 43b24e1d1f..f47ef45ba0 100644 --- a/services/issue/assignee_test.go +++ b/services/issue/assignee_test.go @@ -20,7 +20,7 @@ func TestDeleteNotPassedAssignee(t *testing.T) { // Fake issue with assignees issue, err := issues_model.GetIssueWithAttrsByID(1) assert.NoError(t, err) - assert.EqualValues(t, 1, len(issue.Assignees)) + assert.Len(t, issue.Assignees, 1) user1, err := user_model.GetUserByID(db.DefaultContext, 1) // This user is already assigned (see the definition in fixtures), so running UpdateAssignee should unassign him assert.NoError(t, err) @@ -33,10 +33,10 @@ func TestDeleteNotPassedAssignee(t *testing.T) { // Clean everyone err = DeleteNotPassedAssignee(db.DefaultContext, issue, user1, []*user_model.User{}) assert.NoError(t, err) - assert.EqualValues(t, 0, len(issue.Assignees)) + assert.Empty(t, issue.Assignees) // Check they're gone assert.NoError(t, issue.LoadAssignees(db.DefaultContext)) - assert.EqualValues(t, 0, len(issue.Assignees)) + assert.Empty(t, issue.Assignees) assert.Empty(t, issue.Assignee) } diff --git a/services/issue/issue_test.go b/services/issue/issue_test.go index da0e97c23c..1f6a77096e 100644 --- a/services/issue/issue_test.go +++ b/services/issue/issue_test.go @@ -37,7 +37,7 @@ func TestIssue_DeleteIssue(t *testing.T) { issueIDs, err := issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1) assert.NoError(t, err) - assert.EqualValues(t, 5, len(issueIDs)) + assert.Len(t, issueIDs, 5) issue := &issues_model.Issue{ RepoID: 1, @@ -48,7 +48,7 @@ func TestIssue_DeleteIssue(t *testing.T) { assert.NoError(t, err) issueIDs, err = issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1) assert.NoError(t, err) - assert.EqualValues(t, 4, len(issueIDs)) + assert.Len(t, issueIDs, 4) // check attachment removal attachments, err := repo_model.GetAttachmentsByIssueID(db.DefaultContext, 4) @@ -57,7 +57,7 @@ func TestIssue_DeleteIssue(t *testing.T) { assert.NoError(t, err) err = deleteIssue(db.DefaultContext, issue) assert.NoError(t, err) - assert.EqualValues(t, 2, len(attachments)) + assert.Len(t, attachments, 2) for i := range attachments { attachment, err := repo_model.GetAttachmentByUUID(db.DefaultContext, attachments[i].UUID) assert.Error(t, err) diff --git a/services/repository/adopt_test.go b/services/repository/adopt_test.go index 3f777c425f..c1520e01c9 100644 --- a/services/repository/adopt_test.go +++ b/services/repository/adopt_test.go @@ -30,7 +30,7 @@ func TestCheckUnadoptedRepositories_Add(t *testing.T) { } assert.Equal(t, total, unadopted.index) - assert.Equal(t, end-start, len(unadopted.repositories)) + assert.Len(t, unadopted.repositories, end-start) } func TestCheckUnadoptedRepositories(t *testing.T) { @@ -41,7 +41,7 @@ func TestCheckUnadoptedRepositories(t *testing.T) { unadopted := &unadoptedRepositories{start: 0, end: 100} err := checkUnadoptedRepositories(db.DefaultContext, "notauser", []string{"repo"}, unadopted) assert.NoError(t, err) - assert.Equal(t, 0, len(unadopted.repositories)) + assert.Empty(t, unadopted.repositories) // // Unadopted repository is returned // Existing (adopted) repository is not returned @@ -59,7 +59,7 @@ func TestCheckUnadoptedRepositories(t *testing.T) { unadopted = &unadoptedRepositories{start: 0, end: 100} err = checkUnadoptedRepositories(db.DefaultContext, userName, []string{repoName}, unadopted) assert.NoError(t, err) - assert.Equal(t, 0, len(unadopted.repositories)) + assert.Empty(t, unadopted.repositories) assert.Equal(t, 0, unadopted.index) } |