diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-06-07 07:27:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 07:27:09 +0200 |
commit | 3607f79d7869046d919fed05a21b55b6e61df1fa (patch) | |
tree | 9a176a4d5b67ac3a81ae210e9164d81959221ce0 /integrations | |
parent | 51775f65bc933843199320b040186703a2bb9f51 (diff) | |
download | gitea-3607f79d7869046d919fed05a21b55b6e61df1fa.tar.gz gitea-3607f79d7869046d919fed05a21b55b6e61df1fa.zip |
Fixed assert statements. (#16089)
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_admin_test.go | 4 | ||||
-rw-r--r-- | integrations/api_gpg_keys_test.go | 26 | ||||
-rw-r--r-- | integrations/api_issue_test.go | 4 | ||||
-rw-r--r-- | integrations/api_notification_test.go | 16 | ||||
-rw-r--r-- | integrations/api_oauth2_apps_test.go | 4 | ||||
-rw-r--r-- | integrations/api_org_test.go | 2 | ||||
-rw-r--r-- | integrations/api_pull_review_test.go | 20 | ||||
-rw-r--r-- | integrations/api_repo_tags_test.go | 2 | ||||
-rw-r--r-- | integrations/api_repo_teams_test.go | 4 | ||||
-rw-r--r-- | integrations/api_repo_topic_test.go | 4 | ||||
-rw-r--r-- | integrations/api_team_test.go | 2 | ||||
-rw-r--r-- | integrations/org_test.go | 2 | ||||
-rw-r--r-- | integrations/repo_commits_test.go | 2 | ||||
-rw-r--r-- | integrations/repo_test.go | 12 |
14 files changed, 52 insertions, 52 deletions
diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index b3a0de36d3..b93179d21d 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -195,7 +195,7 @@ func TestAPIEditUser(t *testing.T) { assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string)) user2 := models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User) - assert.Equal(t, false, user2.IsRestricted) + assert.False(t, user2.IsRestricted) bTrue := true req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{ // required @@ -206,5 +206,5 @@ func TestAPIEditUser(t *testing.T) { }) session.MakeRequest(t, req, http.StatusOK) user2 = models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User) - assert.Equal(t, true, user2.IsRestricted) + assert.True(t, user2.IsRestricted) } diff --git a/integrations/api_gpg_keys_test.go b/integrations/api_gpg_keys_test.go index e664c3c256..76a4a1afac 100644 --- a/integrations/api_gpg_keys_test.go +++ b/integrations/api_gpg_keys_test.go @@ -78,42 +78,42 @@ func TestGPGKeys(t *testing.T) { primaryKey1 := keys[0] //Primary key 1 assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID) - assert.EqualValues(t, 1, len(primaryKey1.Emails)) + assert.Len(t, primaryKey1.Emails, 1) assert.EqualValues(t, "user2@example.com", primaryKey1.Emails[0].Email) - assert.EqualValues(t, true, primaryKey1.Emails[0].Verified) + assert.True(t, primaryKey1.Emails[0].Verified) subKey := primaryKey1.SubsKey[0] //Subkey of 38EA3BCED732982C assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID) - assert.EqualValues(t, 0, len(subKey.Emails)) + assert.Empty(t, subKey.Emails) primaryKey2 := keys[1] //Primary key 2 assert.EqualValues(t, "FABF39739FE1E927", primaryKey2.KeyID) - assert.EqualValues(t, 1, len(primaryKey2.Emails)) + assert.Len(t, primaryKey2.Emails, 1) assert.EqualValues(t, "user21@example.com", primaryKey2.Emails[0].Email) - assert.EqualValues(t, false, primaryKey2.Emails[0].Verified) + assert.False(t, primaryKey2.Emails[0].Verified) var key api.GPGKey req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)+"?token="+token) //Primary key 1 resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &key) assert.EqualValues(t, "38EA3BCED732982C", key.KeyID) - assert.EqualValues(t, 1, len(key.Emails)) + assert.Len(t, key.Emails, 1) assert.EqualValues(t, "user2@example.com", key.Emails[0].Email) - assert.EqualValues(t, true, key.Emails[0].Verified) + assert.True(t, key.Emails[0].Verified) req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)+"?token="+token) //Subkey of 38EA3BCED732982C resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &key) assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID) - assert.EqualValues(t, 0, len(key.Emails)) + assert.Empty(t, key.Emails) req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey2.ID, 10)+"?token="+token) //Primary key 2 resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &key) assert.EqualValues(t, "FABF39739FE1E927", key.KeyID) - assert.EqualValues(t, 1, len(key.Emails)) + assert.Len(t, key.Emails, 1) assert.EqualValues(t, "user21@example.com", key.Emails[0].Email) - assert.EqualValues(t, false, key.Emails[0].Verified) + assert.False(t, key.Emails[0].Verified) }) @@ -124,7 +124,7 @@ func TestGPGKeys(t *testing.T) { req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/not-signed?token="+token) resp := session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) - assert.EqualValues(t, false, branch.Commit.Verification.Verified) + assert.False(t, branch.Commit.Verification.Verified) }) t.Run("SignedWithNotValidatedEmail", func(t *testing.T) { @@ -132,7 +132,7 @@ func TestGPGKeys(t *testing.T) { req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign-not-yet-validated?token="+token) resp := session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) - assert.EqualValues(t, false, branch.Commit.Verification.Verified) + assert.False(t, branch.Commit.Verification.Verified) }) t.Run("SignedWithValidEmail", func(t *testing.T) { @@ -140,7 +140,7 @@ func TestGPGKeys(t *testing.T) { req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign?token="+token) resp := session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) - assert.EqualValues(t, true, branch.Commit.Verification.Verified) + assert.True(t, branch.Commit.Verification.Verified) }) }) } diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index f932f79fee..109135b634 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -65,8 +65,8 @@ func TestAPICreateIssue(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusCreated) var apiIssue api.Issue DecodeJSON(t, resp, &apiIssue) - assert.Equal(t, apiIssue.Body, body) - assert.Equal(t, apiIssue.Title, title) + assert.Equal(t, body, apiIssue.Body) + assert.Equal(t, title, apiIssue.Title) models.AssertExistsAndLoadBean(t, &models.Issue{ RepoID: repoBefore.ID, diff --git a/integrations/api_notification_test.go b/integrations/api_notification_test.go index 4204173420..96af14fb82 100644 --- a/integrations/api_notification_test.go +++ b/integrations/api_notification_test.go @@ -45,14 +45,14 @@ func TestAPINotification(t *testing.T) { assert.Len(t, apiNL, 3) assert.EqualValues(t, 4, apiNL[0].ID) - assert.EqualValues(t, true, apiNL[0].Unread) - assert.EqualValues(t, false, apiNL[0].Pinned) + assert.True(t, apiNL[0].Unread) + assert.False(t, apiNL[0].Pinned) assert.EqualValues(t, 3, apiNL[1].ID) - assert.EqualValues(t, false, apiNL[1].Unread) - assert.EqualValues(t, true, apiNL[1].Pinned) + assert.False(t, apiNL[1].Unread) + assert.True(t, apiNL[1].Pinned) assert.EqualValues(t, 2, apiNL[2].ID) - assert.EqualValues(t, false, apiNL[2].Unread) - assert.EqualValues(t, false, apiNL[2].Pinned) + assert.False(t, apiNL[2].Unread) + assert.False(t, apiNL[2].Pinned) // -- GET /repos/{owner}/{repo}/notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?status-types=unread&token=%s", user2.Name, repo1.Name, token)) @@ -74,8 +74,8 @@ func TestAPINotification(t *testing.T) { DecodeJSON(t, resp, &apiN) assert.EqualValues(t, 5, apiN.ID) - assert.EqualValues(t, false, apiN.Pinned) - assert.EqualValues(t, true, apiN.Unread) + assert.False(t, apiN.Pinned) + assert.True(t, apiN.Unread) assert.EqualValues(t, "issue4", apiN.Subject.Title) assert.EqualValues(t, "Issue", apiN.Subject.Type) assert.EqualValues(t, thread5.Issue.APIURL(), apiN.Subject.URL) diff --git a/integrations/api_oauth2_apps_test.go b/integrations/api_oauth2_apps_test.go index 0ba56b6c9f..5c90dbb3bc 100644 --- a/integrations/api_oauth2_apps_test.go +++ b/integrations/api_oauth2_apps_test.go @@ -123,7 +123,7 @@ func testAPIGetOAuth2Application(t *testing.T) { assert.EqualValues(t, existApp.ClientID, expectedApp.ClientID) assert.Len(t, expectedApp.ClientID, 36) assert.Empty(t, expectedApp.ClientSecret) - assert.EqualValues(t, len(expectedApp.RedirectURIs), 1) + assert.Len(t, expectedApp.RedirectURIs, 1) assert.EqualValues(t, existApp.RedirectURIs[0], expectedApp.RedirectURIs[0]) models.AssertExistsAndLoadBean(t, &models.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name}) } @@ -156,7 +156,7 @@ func testAPIUpdateOAuth2Application(t *testing.T) { DecodeJSON(t, resp, &app) expectedApp := app - assert.EqualValues(t, len(expectedApp.RedirectURIs), 2) + assert.Len(t, expectedApp.RedirectURIs, 2) assert.EqualValues(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0]) assert.EqualValues(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1]) models.AssertExistsAndLoadBean(t, &models.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name}) diff --git a/integrations/api_org_test.go b/integrations/api_org_test.go index 551da30326..bc4428b99e 100644 --- a/integrations/api_org_test.go +++ b/integrations/api_org_test.go @@ -69,7 +69,7 @@ func TestAPIOrgCreate(t *testing.T) { // user1 on this org is public var users []*api.User DecodeJSON(t, resp, &users) - assert.EqualValues(t, 1, len(users)) + assert.Len(t, users, 1) assert.EqualValues(t, "user1", users[0].UserName) }) } diff --git a/integrations/api_pull_review_test.go b/integrations/api_pull_review_test.go index 19b05d545b..ebe8539a82 100644 --- a/integrations/api_pull_review_test.go +++ b/integrations/api_pull_review_test.go @@ -37,15 +37,15 @@ func TestAPIPullReview(t *testing.T) { assert.EqualValues(t, 8, reviews[3].ID) assert.EqualValues(t, "APPROVED", reviews[3].State) assert.EqualValues(t, 0, reviews[3].CodeCommentsCount) - assert.EqualValues(t, true, reviews[3].Stale) - assert.EqualValues(t, false, reviews[3].Official) + assert.True(t, reviews[3].Stale) + assert.False(t, reviews[3].Official) assert.EqualValues(t, 10, reviews[5].ID) assert.EqualValues(t, "REQUEST_CHANGES", reviews[5].State) assert.EqualValues(t, 1, reviews[5].CodeCommentsCount) assert.EqualValues(t, -1, reviews[5].Reviewer.ID) // ghost user - assert.EqualValues(t, false, reviews[5].Stale) - assert.EqualValues(t, true, reviews[5].Official) + assert.False(t, reviews[5].Stale) + assert.True(t, reviews[5].Official) // test GetPullReview req = NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, reviews[3].ID, token) @@ -118,14 +118,14 @@ func TestAPIPullReview(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) - assert.EqualValues(t, true, review.Dismissed) + assert.True(t, review.Dismissed) // test dismiss review req = NewRequest(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/undismissals?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) - assert.EqualValues(t, false, review.Dismissed) + assert.False(t, review.Dismissed) // test DeletePullReview req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{ @@ -151,15 +151,15 @@ func TestAPIPullReview(t *testing.T) { assert.EqualValues(t, 11, reviews[0].ID) assert.EqualValues(t, "REQUEST_REVIEW", reviews[0].State) assert.EqualValues(t, 0, reviews[0].CodeCommentsCount) - assert.EqualValues(t, false, reviews[0].Stale) - assert.EqualValues(t, true, reviews[0].Official) + assert.False(t, reviews[0].Stale) + assert.True(t, reviews[0].Official) assert.EqualValues(t, "test_team", reviews[0].ReviewerTeam.Name) assert.EqualValues(t, 12, reviews[1].ID) assert.EqualValues(t, "REQUEST_REVIEW", reviews[1].State) assert.EqualValues(t, 0, reviews[0].CodeCommentsCount) - assert.EqualValues(t, false, reviews[1].Stale) - assert.EqualValues(t, true, reviews[1].Official) + assert.False(t, reviews[1].Stale) + assert.True(t, reviews[1].Official) assert.EqualValues(t, 1, reviews[1].Reviewer.ID) } diff --git a/integrations/api_repo_tags_test.go b/integrations/api_repo_tags_test.go index 9988a48300..1ffec576d8 100644 --- a/integrations/api_repo_tags_test.go +++ b/integrations/api_repo_tags_test.go @@ -28,7 +28,7 @@ func TestAPIReposGetTags(t *testing.T) { var tags []*api.Tag DecodeJSON(t, resp, &tags) - assert.EqualValues(t, 1, len(tags)) + assert.Len(t, tags, 1) assert.Equal(t, "v1.1", tags[0].Name) assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", tags[0].Commit.SHA) assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/git/commits/65f1bf27bc3bf70f64657658635e66094edbcb4d", tags[0].Commit.URL) diff --git a/integrations/api_repo_teams_test.go b/integrations/api_repo_teams_test.go index a07b580346..4a155130b9 100644 --- a/integrations/api_repo_teams_test.go +++ b/integrations/api_repo_teams_test.go @@ -33,12 +33,12 @@ func TestAPIRepoTeams(t *testing.T) { DecodeJSON(t, res, &teams) if assert.Len(t, teams, 2) { assert.EqualValues(t, "Owners", teams[0].Name) - assert.EqualValues(t, false, teams[0].CanCreateOrgRepo) + assert.False(t, teams[0].CanCreateOrgRepo) assert.EqualValues(t, []string{"repo.code", "repo.issues", "repo.pulls", "repo.releases", "repo.wiki", "repo.ext_wiki", "repo.ext_issues"}, teams[0].Units) assert.EqualValues(t, "owner", teams[0].Permission) assert.EqualValues(t, "test_team", teams[1].Name) - assert.EqualValues(t, false, teams[1].CanCreateOrgRepo) + assert.False(t, teams[1].CanCreateOrgRepo) assert.EqualValues(t, []string{"repo.issues"}, teams[1].Units) assert.EqualValues(t, "write", teams[1].Permission) } diff --git a/integrations/api_repo_topic_test.go b/integrations/api_repo_topic_test.go index b96489ae22..5e42bc64bf 100644 --- a/integrations/api_repo_topic_test.go +++ b/integrations/api_repo_topic_test.go @@ -88,7 +88,7 @@ func TestAPIRepoTopic(t *testing.T) { req = NewRequest(t, "GET", url) res = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, res, &topics) - assert.Equal(t, 25, len(topics.TopicNames)) + assert.Len(t, topics.TopicNames, 25) // Test writing more topics than allowed newTopics = append(newTopics, "t26") @@ -115,7 +115,7 @@ func TestAPIRepoTopic(t *testing.T) { req = NewRequest(t, "GET", url) res = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, res, &topics) - assert.Equal(t, 0, len(topics.TopicNames)) + assert.Empty(t, topics.TopicNames) // Test add a topic to repo with write access (requires repo admin access) req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user3.Name, repo3.Name, "topicName", token4) diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go index d893854470..8b202862a1 100644 --- a/integrations/api_team_test.go +++ b/integrations/api_team_test.go @@ -148,7 +148,7 @@ func TestAPITeamSearch(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &results) assert.NotEmpty(t, results.Data) - assert.Equal(t, 1, len(results.Data)) + assert.Len(t, results.Data, 1) assert.Equal(t, "test_team", results.Data[0].Name) // no access if not organization member diff --git a/integrations/org_test.go b/integrations/org_test.go index b0212f4af7..ee61aae6f5 100644 --- a/integrations/org_test.go +++ b/integrations/org_test.go @@ -33,7 +33,7 @@ func TestOrgRepos(t *testing.T) { htmlDoc := NewHTMLParser(t, resp.Body) sel := htmlDoc.doc.Find("a.name") - assert.EqualValues(t, len(repos), len(sel.Nodes)) + assert.Len(t, repos, len(sel.Nodes)) for i := 0; i < len(repos); i++ { assert.EqualValues(t, repos[i], strings.TrimSpace(sel.Eq(i).Text())) } diff --git a/integrations/repo_commits_test.go b/integrations/repo_commits_test.go index 042849db7c..306175d812 100644 --- a/integrations/repo_commits_test.go +++ b/integrations/repo_commits_test.go @@ -66,7 +66,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { doc = NewHTMLParser(t, resp.Body) // Check if commit status is displayed in message column sel := doc.doc.Find("#commits-table tbody tr td.message a.commit-statuses-trigger i.commit-status") - assert.Equal(t, sel.Length(), 1) + assert.Equal(t, 1, sel.Length()) for _, class := range classes { assert.True(t, sel.HasClass(class)) } diff --git a/integrations/repo_test.go b/integrations/repo_test.go index c1652aeb1d..8c4cdf5a96 100644 --- a/integrations/repo_test.go +++ b/integrations/repo_test.go @@ -154,12 +154,12 @@ func TestViewRepoWithSymlinks(t *testing.T) { file := strings.Trim(s.Find("A").Text(), " \t\n") return fmt.Sprintf("%s: %s", file, cls) }) - assert.Equal(t, len(items), 5) - assert.Equal(t, items[0], "a: svg octicon-file-directory") - assert.Equal(t, items[1], "link_b: svg octicon-file-submodule") - assert.Equal(t, items[2], "link_d: svg octicon-file-symlink-file") - assert.Equal(t, items[3], "link_hi: svg octicon-file-symlink-file") - assert.Equal(t, items[4], "link_link: svg octicon-file-symlink-file") + assert.Len(t, items, 5) + assert.Equal(t, "a: svg octicon-file-directory", items[0]) + assert.Equal(t, "link_b: svg octicon-file-submodule", items[1]) + assert.Equal(t, "link_d: svg octicon-file-symlink-file", items[2]) + assert.Equal(t, "link_hi: svg octicon-file-symlink-file", items[3]) + assert.Equal(t, "link_link: svg octicon-file-symlink-file", items[4]) } // TestViewAsRepoAdmin tests PR #2167 |