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 /models | |
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 'models')
-rw-r--r-- | models/db/list_test.go | 2 | ||||
-rw-r--r-- | models/git/branches_test.go | 6 | ||||
-rw-r--r-- | models/issues/pull_test.go | 4 | ||||
-rw-r--r-- | models/issues/tracked_time_test.go | 2 | ||||
-rw-r--r-- | models/unittest/consistency.go | 2 | ||||
-rw-r--r-- | models/user/user_test.go | 6 |
6 files changed, 11 insertions, 11 deletions
diff --git a/models/db/list_test.go b/models/db/list_test.go index 6b9bebd64b..b923dc9c22 100644 --- a/models/db/list_test.go +++ b/models/db/list_test.go @@ -40,7 +40,7 @@ func TestFind(t *testing.T) { var repoUnits []repo_model.RepoUnit err = db.Find(db.DefaultContext, &opts, &repoUnits) assert.NoError(t, err) - assert.EqualValues(t, repoUnitCount, len(repoUnits)) + assert.Len(t, repoUnits, repoUnitCount) cnt, err := db.Count(db.DefaultContext, &opts, new(repo_model.RepoUnit)) assert.NoError(t, err) diff --git a/models/git/branches_test.go b/models/git/branches_test.go index b7df7f243e..5d18d9525e 100644 --- a/models/git/branches_test.go +++ b/models/git/branches_test.go @@ -88,12 +88,12 @@ func TestFindRenamedBranch(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) branch, exist, err := git_model.FindRenamedBranch(db.DefaultContext, 1, "dev") assert.NoError(t, err) - assert.Equal(t, true, exist) + assert.True(t, exist) assert.Equal(t, "master", branch.To) _, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknow") assert.NoError(t, err) - assert.Equal(t, false, exist) + assert.False(t, exist) } func TestRenameBranch(t *testing.T) { @@ -115,7 +115,7 @@ func TestRenameBranch(t *testing.T) { return nil })) - assert.Equal(t, true, _isDefault) + assert.True(t, _isDefault) repo1 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) assert.Equal(t, "main", repo1.DefaultBranch) diff --git a/models/issues/pull_test.go b/models/issues/pull_test.go index bcd33329eb..8d99b2667c 100644 --- a/models/issues/pull_test.go +++ b/models/issues/pull_test.go @@ -109,11 +109,11 @@ func TestHasUnmergedPullRequestsByHeadInfo(t *testing.T) { exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "branch2") assert.NoError(t, err) - assert.Equal(t, true, exist) + assert.True(t, exist) exist, err = issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "not_exist_branch") assert.NoError(t, err) - assert.Equal(t, false, exist) + assert.False(t, exist) } func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) { diff --git a/models/issues/tracked_time_test.go b/models/issues/tracked_time_test.go index becfd79d41..99b977cca5 100644 --- a/models/issues/tracked_time_test.go +++ b/models/issues/tracked_time_test.go @@ -35,7 +35,7 @@ func TestAddTime(t *testing.T) { assert.Equal(t, int64(3661), tt.Time) comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{Type: issues_model.CommentTypeAddTimeManual, PosterID: 3, IssueID: 1}) - assert.Equal(t, comment.Content, "1 hour 1 minute") + assert.Equal(t, "1 hour 1 minute", comment.Content) } func TestGetTrackedTimes(t *testing.T) { diff --git a/models/unittest/consistency.go b/models/unittest/consistency.go index 17ff75c089..41798c6253 100644 --- a/models/unittest/consistency.go +++ b/models/unittest/consistency.go @@ -152,7 +152,7 @@ func init() { Query() assert.NoError(t, err) - assert.EqualValues(t, label.int("NumIssues"), len(issueLabels), "Unexpected number of issue for label id: %d", label.int("ID")) + assert.Len(t, issueLabels, label.int("NumIssues"), "Unexpected number of issue for label id: %d", label.int("ID")) issueIDs := make([]int, len(issueLabels)) for i, issueLabel := range issueLabels { diff --git a/models/user/user_test.go b/models/user/user_test.go index c2314d5c03..cbfcd15463 100644 --- a/models/user/user_test.go +++ b/models/user/user_test.go @@ -36,10 +36,10 @@ func TestGetUserEmailsByNames(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) // ignore none active user email - assert.Equal(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"})) - assert.Equal(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"})) + assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"})) + assert.ElementsMatch(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"})) - assert.Equal(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user7"})) + assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user7"})) } func TestCanCreateOrganization(t *testing.T) { |