Fixed assert statements. (#16089)
This commit is contained in:
parent
51775f65bc
commit
3607f79d78
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -61,11 +61,11 @@ func TestGetByCommentOrIssueID(t *testing.T) {
|
|||
// count of attachments from issue ID
|
||||
attachments, err := GetAttachmentsByIssueID(1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(attachments))
|
||||
assert.Len(t, attachments, 1)
|
||||
|
||||
attachments, err = GetAttachmentsByCommentID(1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(attachments))
|
||||
assert.Len(t, attachments, 2)
|
||||
}
|
||||
|
||||
func TestDeleteAttachments(t *testing.T) {
|
||||
|
@ -122,7 +122,7 @@ func TestGetAttachmentsByUUIDs(t *testing.T) {
|
|||
|
||||
attachList, err := GetAttachmentsByUUIDs(DefaultDBContext(), []string{"a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17", "not-existing-uuid"})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(attachList))
|
||||
assert.Len(t, attachList, 2)
|
||||
assert.Equal(t, "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", attachList[0].UUID)
|
||||
assert.Equal(t, "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17", attachList[1].UUID)
|
||||
assert.Equal(t, int64(1), attachList[0].IssueID)
|
||||
|
|
|
@ -67,7 +67,7 @@ func TestCreateOrStopIssueStopwatch(t *testing.T) {
|
|||
|
||||
assert.NoError(t, CreateOrStopIssueStopwatch(user3, issue1))
|
||||
sw := AssertExistsAndLoadBean(t, &Stopwatch{UserID: 3, IssueID: 1}).(*Stopwatch)
|
||||
assert.Equal(t, true, sw.CreatedUnix <= timeutil.TimeStampNow())
|
||||
assert.LessOrEqual(t, sw.CreatedUnix, timeutil.TimeStampNow())
|
||||
|
||||
assert.NoError(t, CreateOrStopIssueStopwatch(user2, issue2))
|
||||
AssertNotExistsBean(t, &Stopwatch{UserID: 2, IssueID: 2})
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestGetIssueWatch(t *testing.T) {
|
|||
iw, exists, err := GetIssueWatch(2, 2)
|
||||
assert.True(t, exists)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, false, iw.IsWatching)
|
||||
assert.False(t, iw.IsWatching)
|
||||
|
||||
_, exists, err = GetIssueWatch(3, 1)
|
||||
assert.False(t, exists)
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||
ref := AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: pr.ID, RefCommentID: 0}).(*Comment)
|
||||
assert.Equal(t, CommentTypePullRef, ref.Type)
|
||||
assert.Equal(t, pr.RepoID, ref.RefRepoID)
|
||||
assert.Equal(t, true, ref.RefIsPull)
|
||||
assert.True(t, ref.RefIsPull)
|
||||
assert.Equal(t, references.XRefActionCloses, ref.RefAction)
|
||||
|
||||
// Comment on PR to reopen issue #1
|
||||
|
@ -34,7 +34,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||
ref = AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: pr.ID, RefCommentID: c.ID}).(*Comment)
|
||||
assert.Equal(t, CommentTypeCommentRef, ref.Type)
|
||||
assert.Equal(t, pr.RepoID, ref.RefRepoID)
|
||||
assert.Equal(t, true, ref.RefIsPull)
|
||||
assert.True(t, ref.RefIsPull)
|
||||
assert.Equal(t, references.XRefActionReopens, ref.RefAction)
|
||||
|
||||
// Issue mentioning issue #1
|
||||
|
@ -43,7 +43,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||
ref = AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0}).(*Comment)
|
||||
assert.Equal(t, CommentTypeIssueRef, ref.Type)
|
||||
assert.Equal(t, pr.RepoID, ref.RefRepoID)
|
||||
assert.Equal(t, false, ref.RefIsPull)
|
||||
assert.False(t, ref.RefIsPull)
|
||||
assert.Equal(t, references.XRefActionNone, ref.RefAction)
|
||||
|
||||
// Issue #4 to test against
|
||||
|
@ -55,7 +55,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||
ref = AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0}).(*Comment)
|
||||
assert.Equal(t, CommentTypeIssueRef, ref.Type)
|
||||
assert.Equal(t, i.RepoID, ref.RefRepoID)
|
||||
assert.Equal(t, false, ref.RefIsPull)
|
||||
assert.False(t, ref.RefIsPull)
|
||||
assert.Equal(t, references.XRefActionNone, ref.RefAction)
|
||||
|
||||
// Cross-reference to issue #4 with no permission
|
||||
|
|
|
@ -219,11 +219,11 @@ func TestOAuth2AuthorizationCode_GenerateRedirectURI(t *testing.T) {
|
|||
|
||||
redirect, err := code.GenerateRedirectURI("thestate")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, redirect.String(), "https://example.com/callback?code=thecode&state=thestate")
|
||||
assert.Equal(t, "https://example.com/callback?code=thecode&state=thestate", redirect.String())
|
||||
|
||||
redirect, err = code.GenerateRedirectURI("")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, redirect.String(), "https://example.com/callback?code=thecode")
|
||||
assert.Equal(t, "https://example.com/callback?code=thecode", redirect.String())
|
||||
}
|
||||
|
||||
func TestOAuth2AuthorizationCode_Invalidate(t *testing.T) {
|
||||
|
|
|
@ -453,7 +453,7 @@ func TestAddOrgUser(t *testing.T) {
|
|||
assert.NoError(t, AddOrgUser(orgID, userID))
|
||||
ou := &OrgUser{OrgID: orgID, UID: userID}
|
||||
AssertExistsAndLoadBean(t, ou)
|
||||
assert.Equal(t, ou.IsPublic, isPublic)
|
||||
assert.Equal(t, isPublic, ou.IsPublic)
|
||||
org = AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
|
||||
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
|
||||
}
|
||||
|
@ -589,9 +589,9 @@ func TestHasOrgVisibleTypePublic(t *testing.T) {
|
|||
test1 := HasOrgVisible(org, owner)
|
||||
test2 := HasOrgVisible(org, user3)
|
||||
test3 := HasOrgVisible(org, nil)
|
||||
assert.Equal(t, test1, true) // owner of org
|
||||
assert.Equal(t, test2, true) // user not a part of org
|
||||
assert.Equal(t, test3, true) // logged out user
|
||||
assert.True(t, test1) // owner of org
|
||||
assert.True(t, test2) // user not a part of org
|
||||
assert.True(t, test3) // logged out user
|
||||
}
|
||||
|
||||
func TestHasOrgVisibleTypeLimited(t *testing.T) {
|
||||
|
@ -612,9 +612,9 @@ func TestHasOrgVisibleTypeLimited(t *testing.T) {
|
|||
test1 := HasOrgVisible(org, owner)
|
||||
test2 := HasOrgVisible(org, user3)
|
||||
test3 := HasOrgVisible(org, nil)
|
||||
assert.Equal(t, test1, true) // owner of org
|
||||
assert.Equal(t, test2, true) // user not a part of org
|
||||
assert.Equal(t, test3, false) // logged out user
|
||||
assert.True(t, test1) // owner of org
|
||||
assert.True(t, test2) // user not a part of org
|
||||
assert.False(t, test3) // logged out user
|
||||
}
|
||||
|
||||
func TestHasOrgVisibleTypePrivate(t *testing.T) {
|
||||
|
@ -635,9 +635,9 @@ func TestHasOrgVisibleTypePrivate(t *testing.T) {
|
|||
test1 := HasOrgVisible(org, owner)
|
||||
test2 := HasOrgVisible(org, user3)
|
||||
test3 := HasOrgVisible(org, nil)
|
||||
assert.Equal(t, test1, true) // owner of org
|
||||
assert.Equal(t, test2, false) // user not a part of org
|
||||
assert.Equal(t, test3, false) // logged out user
|
||||
assert.True(t, test1) // owner of org
|
||||
assert.False(t, test2) // user not a part of org
|
||||
assert.False(t, test3) // logged out user
|
||||
}
|
||||
|
||||
func TestGetUsersWhoCanCreateOrgRepo(t *testing.T) {
|
||||
|
|
|
@ -25,7 +25,7 @@ text/*.txt
|
|||
|
||||
func TestGiteaTemplate(t *testing.T) {
|
||||
gt := GiteaTemplate{Content: giteaTemplate}
|
||||
assert.Equal(t, len(gt.Globs()), 3)
|
||||
assert.Len(t, gt.Globs(), 3)
|
||||
|
||||
tt := []struct {
|
||||
Path string
|
||||
|
|
|
@ -61,8 +61,8 @@ func TestMetas(t *testing.T) {
|
|||
metas = repo.ComposeMetas()
|
||||
assert.Contains(t, metas, "org")
|
||||
assert.Contains(t, metas, "teams")
|
||||
assert.Equal(t, metas["org"], "user3")
|
||||
assert.Equal(t, metas["teams"], ",owners,team1,")
|
||||
assert.Equal(t, "user3", metas["org"])
|
||||
assert.Equal(t, ",owners,team1,", metas["teams"])
|
||||
}
|
||||
|
||||
func TestGetRepositoryCount(t *testing.T) {
|
||||
|
@ -111,7 +111,7 @@ func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
|
|||
_, err = x.ID(3).Get(&act)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, act.IsPrivate)
|
||||
assert.True(t, act.IsPrivate)
|
||||
}
|
||||
|
||||
func TestGetUserFork(t *testing.T) {
|
||||
|
@ -199,13 +199,13 @@ func TestRepoGetReviewers(t *testing.T) {
|
|||
|
||||
reviewers, err := repo1.GetReviewers(2, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 4, len(reviewers))
|
||||
assert.Len(t, reviewers, 4)
|
||||
|
||||
// test private repo
|
||||
repo2 := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
||||
reviewers, err = repo2.GetReviewers(2, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(reviewers))
|
||||
assert.Empty(t, reviewers)
|
||||
}
|
||||
|
||||
func TestRepoGetReviewerTeams(t *testing.T) {
|
||||
|
@ -219,5 +219,5 @@ func TestRepoGetReviewerTeams(t *testing.T) {
|
|||
repo3 := AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository)
|
||||
teams, err = repo3.GetReviewerTeams()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(teams))
|
||||
assert.Len(t, teams, 2)
|
||||
}
|
||||
|
|
|
@ -19,31 +19,31 @@ func TestAddTopic(t *testing.T) {
|
|||
|
||||
topics, err := FindTopics(&FindTopicOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, totalNrOfTopics, len(topics))
|
||||
assert.Len(t, topics, totalNrOfTopics)
|
||||
|
||||
topics, err = FindTopics(&FindTopicOptions{
|
||||
ListOptions: ListOptions{Page: 1, PageSize: 2},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(topics))
|
||||
assert.Len(t, topics, 2)
|
||||
|
||||
topics, err = FindTopics(&FindTopicOptions{
|
||||
RepoID: 1,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, repo1NrOfTopics, len(topics))
|
||||
assert.Len(t, topics, repo1NrOfTopics)
|
||||
|
||||
assert.NoError(t, SaveTopics(2, "golang"))
|
||||
repo2NrOfTopics = 1
|
||||
topics, err = FindTopics(&FindTopicOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, totalNrOfTopics, len(topics))
|
||||
assert.Len(t, topics, totalNrOfTopics)
|
||||
|
||||
topics, err = FindTopics(&FindTopicOptions{
|
||||
RepoID: 2,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, repo2NrOfTopics, len(topics))
|
||||
assert.Len(t, topics, repo2NrOfTopics)
|
||||
|
||||
assert.NoError(t, SaveTopics(2, "golang", "gitea"))
|
||||
repo2NrOfTopics = 2
|
||||
|
@ -54,13 +54,13 @@ func TestAddTopic(t *testing.T) {
|
|||
|
||||
topics, err = FindTopics(&FindTopicOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, totalNrOfTopics, len(topics))
|
||||
assert.Len(t, topics, totalNrOfTopics)
|
||||
|
||||
topics, err = FindTopics(&FindTopicOptions{
|
||||
RepoID: 2,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, repo2NrOfTopics, len(topics))
|
||||
assert.Len(t, topics, repo2NrOfTopics)
|
||||
}
|
||||
|
||||
func TestTopicValidator(t *testing.T) {
|
||||
|
|
|
@ -52,8 +52,8 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
|
|||
// Get the heatmap and compare
|
||||
heatmap, err := GetUserHeatmapDataByUser(user, doer)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, len(actions), len(heatmap), "invalid action count: did the test data became too old?")
|
||||
assert.Equal(t, tc.CountResult, len(heatmap), fmt.Sprintf("testcase %d", i))
|
||||
assert.Len(t, heatmap, len(actions), "invalid action count: did the test data became too old?")
|
||||
assert.Len(t, heatmap, tc.CountResult, fmt.Sprintf("testcase %d", i))
|
||||
|
||||
// Test JSON rendering
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
|
|
@ -129,14 +129,14 @@ func TestMakeEmailPrimary(t *testing.T) {
|
|||
}
|
||||
err := MakeEmailPrimary(email)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, ErrEmailNotExist.Error(), err.Error())
|
||||
assert.EqualError(t, err, ErrEmailNotExist.Error())
|
||||
|
||||
email = &EmailAddress{
|
||||
Email: "user11@example.com",
|
||||
}
|
||||
err = MakeEmailPrimary(email)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, ErrEmailNotActivated.Error(), err.Error())
|
||||
assert.EqualError(t, err, ErrEmailNotActivated.Error())
|
||||
|
||||
email = &EmailAddress{
|
||||
Email: "user9999999@example.com",
|
||||
|
@ -232,6 +232,6 @@ func TestListEmails(t *testing.T) {
|
|||
}
|
||||
emails, count, err = SearchEmails(opts)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 5, len(emails))
|
||||
assert.True(t, count > int64(len(emails)))
|
||||
assert.Len(t, emails, 5)
|
||||
assert.Greater(t, count, int64(len(emails)))
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@ func TestGetUserOpenIDs(t *testing.T) {
|
|||
|
||||
oids, err := GetUserOpenIDs(int64(1))
|
||||
if assert.NoError(t, err) && assert.Len(t, oids, 2) {
|
||||
assert.Equal(t, oids[0].URI, "https://user1.domain1.tld/")
|
||||
assert.Equal(t, "https://user1.domain1.tld/", oids[0].URI)
|
||||
assert.False(t, oids[0].Show)
|
||||
assert.Equal(t, oids[1].URI, "http://user1.domain2.tld/")
|
||||
assert.Equal(t, "http://user1.domain2.tld/", oids[1].URI)
|
||||
assert.True(t, oids[1].Show)
|
||||
}
|
||||
|
||||
oids, err = GetUserOpenIDs(int64(2))
|
||||
if assert.NoError(t, err) && assert.Len(t, oids, 1) {
|
||||
assert.Equal(t, oids[0].URI, "https://domain1.tld/user2/")
|
||||
assert.Equal(t, "https://domain1.tld/user2/", oids[0].URI)
|
||||
assert.True(t, oids[0].Show)
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ func TestGetUserByOpenID(t *testing.T) {
|
|||
|
||||
user, err := GetUserByOpenID("https://user1.domain1.tld")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, user.ID, int64(1))
|
||||
assert.Equal(t, int64(1), user.ID)
|
||||
}
|
||||
|
||||
user, err = GetUserByOpenID("https://domain1.tld/user2/")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, user.ID, int64(2))
|
||||
assert.Equal(t, int64(2), user.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,14 +386,14 @@ func TestGetMaileableUsersByIDs(t *testing.T) {
|
|||
|
||||
results, err := GetMaileableUsersByIDs([]int64{1, 4}, false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(results))
|
||||
assert.Len(t, results, 1)
|
||||
if len(results) > 1 {
|
||||
assert.Equal(t, results[0].ID, 1)
|
||||
}
|
||||
|
||||
results, err = GetMaileableUsersByIDs([]int64{1, 4}, true)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(results))
|
||||
assert.Len(t, results, 2)
|
||||
if len(results) > 2 {
|
||||
assert.Equal(t, results[0].ID, 1)
|
||||
assert.Equal(t, results[1].ID, 4)
|
||||
|
@ -457,7 +457,7 @@ ssh-dss AAAAB3NzaC1kc3MAAACBAOChCC7lf6Uo9n7BmZ6M8St19PZf4Tn59NriyboW2x/DZuYAz3ib
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
assert.Equal(t, kase.number, len(keys))
|
||||
assert.Len(t, keys, kase.number)
|
||||
|
||||
for _, key := range keys {
|
||||
assert.Contains(t, kase.keyContents, key.Content)
|
||||
|
|
|
@ -15,6 +15,6 @@ import (
|
|||
func TestPamAuth(t *testing.T) {
|
||||
result, err := Auth("gitea", "user1", "false-pwd")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, "Authentication failure", err.Error())
|
||||
assert.EqualError(t, err, "Authentication failure")
|
||||
assert.Len(t, result, 0)
|
||||
}
|
||||
|
|
|
@ -223,9 +223,9 @@ func TestInt64sToMap(t *testing.T) {
|
|||
|
||||
func TestInt64sContains(t *testing.T) {
|
||||
assert.Equal(t, map[int64]bool{}, Int64sToMap([]int64{}))
|
||||
assert.Equal(t, true, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 1))
|
||||
assert.Equal(t, true, Int64sContains([]int64{2323}, 2323))
|
||||
assert.Equal(t, false, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 232))
|
||||
assert.True(t, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 1))
|
||||
assert.True(t, Int64sContains([]int64{2323}, 2323))
|
||||
assert.False(t, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 232))
|
||||
}
|
||||
|
||||
func TestIsLetter(t *testing.T) {
|
||||
|
@ -249,7 +249,7 @@ func TestIsLetter(t *testing.T) {
|
|||
|
||||
func TestSetupGiteaRoot(t *testing.T) {
|
||||
_ = os.Setenv("GITEA_ROOT", "test")
|
||||
assert.EqualValues(t, "test", SetupGiteaRoot())
|
||||
assert.Equal(t, "test", SetupGiteaRoot())
|
||||
_ = os.Setenv("GITEA_ROOT", "")
|
||||
assert.NotEqual(t, "test", SetupGiteaRoot())
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestParseTreeEntries(t *testing.T) {
|
|||
for _, testCase := range testCases {
|
||||
entries, err := ParseTreeEntries([]byte(testCase.Input))
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, len(testCase.Expected), len(entries))
|
||||
assert.Len(t, entries, len(testCase.Expected))
|
||||
for i, entry := range entries {
|
||||
assert.EqualValues(t, testCase.Expected[i].ID, entry.ID)
|
||||
assert.EqualValues(t, testCase.Expected[i].name, entry.name)
|
||||
|
|
|
@ -72,9 +72,9 @@ func TestIsCommitInBranch(t *testing.T) {
|
|||
|
||||
result, err := bareRepo1.IsCommitInBranch("2839944139e0de9737a044f78b0e4b40d989a9e3", "branch1")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, result)
|
||||
assert.True(t, result)
|
||||
|
||||
result, err = bareRepo1.IsCommitInBranch("2839944139e0de9737a044f78b0e4b40d989a9e3", "branch2")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, false, result)
|
||||
assert.False(t, result)
|
||||
}
|
||||
|
|
|
@ -71,33 +71,33 @@ func TestFollowLink(t *testing.T) {
|
|||
// should be able to dereference to target
|
||||
target, err := lnk.FollowLink()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, target.Name(), "hello")
|
||||
assert.Equal(t, "hello", target.Name())
|
||||
assert.False(t, target.IsLink())
|
||||
assert.Equal(t, target.ID.String(), "b14df6442ea5a1b382985a6549b85d435376c351")
|
||||
assert.Equal(t, "b14df6442ea5a1b382985a6549b85d435376c351", target.ID.String())
|
||||
|
||||
// should error when called on normal file
|
||||
target, err = commit.Tree.GetTreeEntryByPath("file1.txt")
|
||||
assert.NoError(t, err)
|
||||
_, err = target.FollowLink()
|
||||
assert.Equal(t, err.Error(), "file1.txt: not a symlink")
|
||||
assert.EqualError(t, err, "file1.txt: not a symlink")
|
||||
|
||||
// should error for broken links
|
||||
target, err = commit.Tree.GetTreeEntryByPath("foo/broken_link")
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, target.IsLink())
|
||||
_, err = target.FollowLink()
|
||||
assert.Equal(t, err.Error(), "broken_link: broken link")
|
||||
assert.EqualError(t, err, "broken_link: broken link")
|
||||
|
||||
// should error for external links
|
||||
target, err = commit.Tree.GetTreeEntryByPath("foo/outside_repo")
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, target.IsLink())
|
||||
_, err = target.FollowLink()
|
||||
assert.Equal(t, err.Error(), "outside_repo: points outside of repo")
|
||||
assert.EqualError(t, err, "outside_repo: points outside of repo")
|
||||
|
||||
// testing fix for short link bug
|
||||
target, err = commit.Tree.GetTreeEntryByPath("foo/link_short")
|
||||
assert.NoError(t, err)
|
||||
_, err = target.FollowLink()
|
||||
assert.Equal(t, err.Error(), "link_short: broken link")
|
||||
assert.EqualError(t, err, "link_short: broken link")
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func testIndexer(name string, t *testing.T, indexer Indexer) {
|
|||
total, res, langs, err := indexer.Search(kw.RepoIDs, "", kw.Keyword, 1, 10, false)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, len(kw.IDs), total)
|
||||
assert.EqualValues(t, kw.Langs, len(langs))
|
||||
assert.Len(t, langs, kw.Langs)
|
||||
|
||||
var ids = make([]int64, 0, len(res))
|
||||
for _, hit := range res {
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestHTTPClientDownload(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "download", batchRequest.Operation)
|
||||
assert.Equal(t, 1, len(batchRequest.Objects))
|
||||
assert.Len(t, batchRequest.Objects, 1)
|
||||
assert.Equal(t, oid, batchRequest.Objects[0].Oid)
|
||||
assert.Equal(t, size, batchRequest.Objects[0].Size)
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ import (
|
|||
func TestStringContent(t *testing.T) {
|
||||
p := Pointer{Oid: "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393", Size: 1234}
|
||||
expected := "version https://git-lfs.github.com/spec/v1\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 1234\n"
|
||||
assert.Equal(t, p.StringContent(), expected)
|
||||
assert.Equal(t, expected, p.StringContent())
|
||||
}
|
||||
|
||||
func TestRelativePath(t *testing.T) {
|
||||
p := Pointer{Oid: "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393"}
|
||||
expected := path.Join("4d", "7a", "214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393")
|
||||
assert.Equal(t, p.RelativePath(), expected)
|
||||
assert.Equal(t, expected, p.RelativePath())
|
||||
|
||||
p2 := Pointer{Oid: "4d7a"}
|
||||
assert.Equal(t, p2.RelativePath(), "4d7a")
|
||||
assert.Equal(t, "4d7a", p2.RelativePath())
|
||||
}
|
||||
|
||||
func TestIsValid(t *testing.T) {
|
||||
|
@ -48,8 +48,8 @@ func TestGeneratePointer(t *testing.T) {
|
|||
p, err := GeneratePointer(strings.NewReader("Gitea"))
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, p.IsValid())
|
||||
assert.Equal(t, p.Oid, "94cb57646c54a297c9807697e80a30946f79a4b82cb079d2606847825b1812cc")
|
||||
assert.Equal(t, p.Size, int64(5))
|
||||
assert.Equal(t, "94cb57646c54a297c9807697e80a30946f79a4b82cb079d2606847825b1812cc", p.Oid)
|
||||
assert.Equal(t, int64(5), p.Size)
|
||||
}
|
||||
|
||||
func TestReadPointerFromBuffer(t *testing.T) {
|
||||
|
@ -84,20 +84,20 @@ func TestReadPointerFromBuffer(t *testing.T) {
|
|||
p, err = ReadPointerFromBuffer([]byte("version https://git-lfs.github.com/spec/v1\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 1234\n"))
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, p.IsValid())
|
||||
assert.Equal(t, p.Oid, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393")
|
||||
assert.Equal(t, p.Size, int64(1234))
|
||||
assert.Equal(t, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393", p.Oid)
|
||||
assert.Equal(t, int64(1234), p.Size)
|
||||
|
||||
p, err = ReadPointerFromBuffer([]byte("version https://git-lfs.github.com/spec/v1\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 1234\ntest"))
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, p.IsValid())
|
||||
assert.Equal(t, p.Oid, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393")
|
||||
assert.Equal(t, p.Size, int64(1234))
|
||||
assert.Equal(t, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393", p.Oid)
|
||||
assert.Equal(t, int64(1234), p.Size)
|
||||
}
|
||||
|
||||
func TestReadPointer(t *testing.T) {
|
||||
p, err := ReadPointer(strings.NewReader("version https://git-lfs.github.com/spec/v1\noid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 1234\n"))
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, p.IsValid())
|
||||
assert.Equal(t, p.Oid, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393")
|
||||
assert.Equal(t, p.Size, int64(1234))
|
||||
assert.Equal(t, "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393", p.Oid)
|
||||
assert.Equal(t, int64(1234), p.Size)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestConsoleLoggerMinimalConfig(t *testing.T) {
|
|||
assert.Equal(t, prefix, realCW.Prefix)
|
||||
assert.Equal(t, "", string(written))
|
||||
cw.Close()
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -97,20 +97,20 @@ func TestConsoleLogger(t *testing.T) {
|
|||
expected := fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
cw.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = DEBUG
|
||||
expected = ""
|
||||
cw.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
event.level = TRACE
|
||||
expected = ""
|
||||
cw.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
nonMatchEvent := Event{
|
||||
level: INFO,
|
||||
|
@ -124,15 +124,15 @@ func TestConsoleLogger(t *testing.T) {
|
|||
expected = ""
|
||||
cw.LogEvent(&nonMatchEvent)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
event.level = WARN
|
||||
expected = fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
cw.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
cw.Close()
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestFileLoggerFails(t *testing.T) {
|
|||
|
||||
fileLogger := NewFileLogger()
|
||||
//realFileLogger, ok := fileLogger.(*FileLogger)
|
||||
//assert.Equal(t, true, ok)
|
||||
//assert.True(t, ok)
|
||||
|
||||
// Fail if there is bad json
|
||||
err = fileLogger.Init("{")
|
||||
|
@ -161,7 +161,7 @@ func TestCompressFileLogger(t *testing.T) {
|
|||
|
||||
fileLogger := NewFileLogger()
|
||||
realFileLogger, ok := fileLogger.(*FileLogger)
|
||||
assert.Equal(t, true, ok)
|
||||
assert.True(t, ok)
|
||||
|
||||
location, _ := time.LoadLocation("EST")
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ func baseConsoleTest(t *testing.T, logger *MultiChannelledLogger) (chan []byte,
|
|||
channelledLog := m.GetEventLogger("console")
|
||||
assert.NotEmpty(t, channelledLog)
|
||||
realChanLog, ok := channelledLog.(*ChannelledLog)
|
||||
assert.Equal(t, true, ok)
|
||||
assert.True(t, ok)
|
||||
realCL, ok := realChanLog.loggerProvider.(*ConsoleLogger)
|
||||
assert.Equal(t, true, ok)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, INFO, realCL.Level)
|
||||
realCL.out = c
|
||||
|
||||
|
@ -38,20 +38,20 @@ func baseConsoleTest(t *testing.T, logger *MultiChannelledLogger) (chan []byte,
|
|||
logger.Log(0, INFO, format, args...)
|
||||
line := <-written
|
||||
assert.Contains(t, string(line), fmt.Sprintf(format, args...))
|
||||
assert.Equal(t, false, <-closed)
|
||||
assert.False(t, <-closed)
|
||||
|
||||
format = "test2: %s"
|
||||
logger.Warn(format, args...)
|
||||
line = <-written
|
||||
|
||||
assert.Contains(t, string(line), fmt.Sprintf(format, args...))
|
||||
assert.Equal(t, false, <-closed)
|
||||
assert.False(t, <-closed)
|
||||
|
||||
format = "testerror: %s"
|
||||
logger.Error(format, args...)
|
||||
line = <-written
|
||||
assert.Contains(t, string(line), fmt.Sprintf(format, args...))
|
||||
assert.Equal(t, false, <-closed)
|
||||
assert.False(t, <-closed)
|
||||
return written, closed
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func TestNewLoggerUnexported(t *testing.T) {
|
|||
out := logger.MultiChannelledLog.GetEventLogger("console")
|
||||
assert.NotEmpty(t, out)
|
||||
chanlog, ok := out.(*ChannelledLog)
|
||||
assert.Equal(t, true, ok)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "console", chanlog.provider)
|
||||
assert.Equal(t, INFO, logger.GetLevel())
|
||||
baseConsoleTest(t, logger)
|
||||
|
@ -74,11 +74,11 @@ func TestNewLoggger(t *testing.T) {
|
|||
logger := NewLogger(0, "console", "console", fmt.Sprintf(`{"level":"%s"}`, level.String()))
|
||||
|
||||
assert.Equal(t, INFO, GetLevel())
|
||||
assert.Equal(t, false, IsTrace())
|
||||
assert.Equal(t, false, IsDebug())
|
||||
assert.Equal(t, true, IsInfo())
|
||||
assert.Equal(t, true, IsWarn())
|
||||
assert.Equal(t, true, IsError())
|
||||
assert.False(t, IsTrace())
|
||||
assert.False(t, IsDebug())
|
||||
assert.True(t, IsInfo())
|
||||
assert.True(t, IsWarn())
|
||||
assert.True(t, IsError())
|
||||
|
||||
written, closed := baseConsoleTest(t, logger)
|
||||
|
||||
|
@ -88,17 +88,17 @@ func TestNewLoggger(t *testing.T) {
|
|||
Log(0, INFO, format, args...)
|
||||
line := <-written
|
||||
assert.Contains(t, string(line), fmt.Sprintf(format, args...))
|
||||
assert.Equal(t, false, <-closed)
|
||||
assert.False(t, <-closed)
|
||||
|
||||
Info(format, args...)
|
||||
line = <-written
|
||||
assert.Contains(t, string(line), fmt.Sprintf(format, args...))
|
||||
assert.Equal(t, false, <-closed)
|
||||
assert.False(t, <-closed)
|
||||
|
||||
go DelLogger("console")
|
||||
line = <-written
|
||||
assert.Equal(t, "", string(line))
|
||||
assert.Equal(t, true, <-closed)
|
||||
assert.True(t, <-closed)
|
||||
}
|
||||
|
||||
func TestNewLogggerRecreate(t *testing.T) {
|
||||
|
@ -106,11 +106,11 @@ func TestNewLogggerRecreate(t *testing.T) {
|
|||
NewLogger(0, "console", "console", fmt.Sprintf(`{"level":"%s"}`, level.String()))
|
||||
|
||||
assert.Equal(t, INFO, GetLevel())
|
||||
assert.Equal(t, false, IsTrace())
|
||||
assert.Equal(t, false, IsDebug())
|
||||
assert.Equal(t, true, IsInfo())
|
||||
assert.Equal(t, true, IsWarn())
|
||||
assert.Equal(t, true, IsError())
|
||||
assert.False(t, IsTrace())
|
||||
assert.False(t, IsDebug())
|
||||
assert.True(t, IsInfo())
|
||||
assert.True(t, IsWarn())
|
||||
assert.True(t, IsError())
|
||||
|
||||
format := "test: %s"
|
||||
args := []interface{}{"A"}
|
||||
|
@ -120,11 +120,11 @@ func TestNewLogggerRecreate(t *testing.T) {
|
|||
NewLogger(0, "console", "console", fmt.Sprintf(`{"level":"%s"}`, level.String()))
|
||||
|
||||
assert.Equal(t, INFO, GetLevel())
|
||||
assert.Equal(t, false, IsTrace())
|
||||
assert.Equal(t, false, IsDebug())
|
||||
assert.Equal(t, true, IsInfo())
|
||||
assert.Equal(t, true, IsWarn())
|
||||
assert.Equal(t, true, IsError())
|
||||
assert.False(t, IsTrace())
|
||||
assert.False(t, IsDebug())
|
||||
assert.True(t, IsInfo())
|
||||
assert.True(t, IsWarn())
|
||||
assert.True(t, IsError())
|
||||
|
||||
Log(0, INFO, format, args...)
|
||||
|
||||
|
@ -150,5 +150,5 @@ func TestNewNamedLogger(t *testing.T) {
|
|||
go DelNamedLogger("test")
|
||||
line := <-written
|
||||
assert.Equal(t, "", string(line))
|
||||
assert.Equal(t, true, <-closed)
|
||||
assert.True(t, <-closed)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestSMTPLogger(t *testing.T) {
|
|||
|
||||
logger := NewSMTPLogger()
|
||||
smtpLogger, ok := logger.(*SMTPLogger)
|
||||
assert.Equal(t, true, ok)
|
||||
assert.True(t, ok)
|
||||
|
||||
err := logger.Init(fmt.Sprintf("{\"prefix\":\"%s\",\"level\":\"%s\",\"flags\":%d,\"username\":\"%s\",\"password\":\"%s\",\"host\":\"%s\",\"subject\":\"%s\",\"sendTos\":[\"%s\",\"%s\"]}", prefix, level.String(), flags, username, password, host, subject, sendTos[0], sendTos[1]))
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -64,44 +64,44 @@ func TestBaseLogger(t *testing.T) {
|
|||
expected := fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = DEBUG
|
||||
expected = ""
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
event.level = TRACE
|
||||
expected = ""
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
|
||||
event.level = WARN
|
||||
expected = fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = ERROR
|
||||
expected = fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = CRITICAL
|
||||
expected = fmt.Sprintf("%s%s %s:%d:%s [%c] %s\n", prefix, dateString, event.filename, event.line, event.caller, strings.ToUpper(event.level.String())[0], event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
b.Close()
|
||||
assert.Equal(t, true, closed)
|
||||
assert.True(t, closed)
|
||||
}
|
||||
|
||||
func TestBaseLoggerDated(t *testing.T) {
|
||||
|
@ -142,46 +142,46 @@ func TestBaseLoggerDated(t *testing.T) {
|
|||
expected := fmt.Sprintf("%s%s %s:%d [%s] %s", prefix, dateString, "FILENAME", event.line, strings.ToUpper(event.level.String()), event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = INFO
|
||||
expected = ""
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = ERROR
|
||||
expected = fmt.Sprintf("%s%s %s:%d [%s] %s", prefix, dateString, "FILENAME", event.line, strings.ToUpper(event.level.String()), event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = DEBUG
|
||||
expected = ""
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = CRITICAL
|
||||
expected = fmt.Sprintf("%s%s %s:%d [%s] %s", prefix, dateString, "FILENAME", event.line, strings.ToUpper(event.level.String()), event.msg)
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.level = TRACE
|
||||
expected = ""
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
b.Close()
|
||||
assert.Equal(t, true, closed)
|
||||
assert.True(t, closed)
|
||||
}
|
||||
|
||||
func TestBaseLoggerMultiLineNoFlagsRegexp(t *testing.T) {
|
||||
|
@ -222,20 +222,20 @@ func TestBaseLoggerMultiLineNoFlagsRegexp(t *testing.T) {
|
|||
expected := "TEST\n\tMESSAGE\n\tTEST\n"
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.filename = "ELSEWHERE"
|
||||
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, "", string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event.caller = "FILENAME"
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
event = Event{
|
||||
|
@ -249,9 +249,8 @@ func TestBaseLoggerMultiLineNoFlagsRegexp(t *testing.T) {
|
|||
expected = "TEST\n\tFILENAME\n\tTEST\n"
|
||||
b.LogEvent(&event)
|
||||
assert.Equal(t, expected, string(written))
|
||||
assert.Equal(t, false, closed)
|
||||
assert.False(t, closed)
|
||||
written = written[:0]
|
||||
|
||||
}
|
||||
|
||||
func TestBrokenRegexp(t *testing.T) {
|
||||
|
@ -273,5 +272,5 @@ func TestBrokenRegexp(t *testing.T) {
|
|||
b.NewWriterLogger(c)
|
||||
assert.Empty(t, b.regexp)
|
||||
b.Close()
|
||||
assert.Equal(t, true, closed)
|
||||
assert.True(t, closed)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestExtractMetadata(t *testing.T) {
|
|||
var meta structs.IssueTemplate
|
||||
body, err := ExtractMetadata(fmt.Sprintf("%s\n%s\n%s\n%s", sepTest, frontTest, sepTest, bodyTest), &meta)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, body, bodyTest)
|
||||
assert.Equal(t, bodyTest, body)
|
||||
assert.Equal(t, metaTest, meta)
|
||||
assert.True(t, meta.Valid())
|
||||
})
|
||||
|
@ -39,7 +39,7 @@ func TestExtractMetadata(t *testing.T) {
|
|||
var meta structs.IssueTemplate
|
||||
body, err := ExtractMetadata(fmt.Sprintf("%s\n%s\n%s", sepTest, frontTest, sepTest), &meta)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, body, "")
|
||||
assert.Equal(t, "", body)
|
||||
assert.Equal(t, metaTest, meta)
|
||||
assert.True(t, meta.Valid())
|
||||
})
|
||||
|
|
|
@ -158,13 +158,13 @@ func TestGiteaDownloadRepo(t *testing.T) {
|
|||
|
||||
issues, isEnd, err := downloader.GetIssues(1, 50)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 7, len(issues))
|
||||
assert.Len(t, issues, 7)
|
||||
assert.True(t, isEnd)
|
||||
assert.EqualValues(t, "open", issues[0].State)
|
||||
|
||||
issues, isEnd, err = downloader.GetIssues(3, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(issues))
|
||||
assert.Len(t, issues, 2)
|
||||
assert.False(t, isEnd)
|
||||
|
||||
var (
|
||||
|
|
|
@ -59,18 +59,18 @@ func TestGiteaUploadRepo(t *testing.T) {
|
|||
State: structs.StateOpen,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(milestones))
|
||||
assert.Len(t, milestones, 1)
|
||||
|
||||
milestones, err = models.GetMilestones(models.GetMilestonesOption{
|
||||
RepoID: repo.ID,
|
||||
State: structs.StateClosed,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, len(milestones))
|
||||
assert.Empty(t, milestones)
|
||||
|
||||
labels, err := models.GetLabelsByRepoID(repo.ID, "", models.ListOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 11, len(labels))
|
||||
assert.Len(t, labels, 11)
|
||||
|
||||
releases, err := models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{
|
||||
ListOptions: models.ListOptions{
|
||||
|
@ -80,7 +80,7 @@ func TestGiteaUploadRepo(t *testing.T) {
|
|||
IncludeTags: true,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 8, len(releases))
|
||||
assert.Len(t, releases, 8)
|
||||
|
||||
releases, err = models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{
|
||||
ListOptions: models.ListOptions{
|
||||
|
@ -90,7 +90,7 @@ func TestGiteaUploadRepo(t *testing.T) {
|
|||
IncludeTags: false,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(releases))
|
||||
assert.Len(t, releases, 1)
|
||||
|
||||
issues, err := models.Issues(&models.IssuesOptions{
|
||||
RepoIDs: []int64{repo.ID},
|
||||
|
@ -98,16 +98,16 @@ func TestGiteaUploadRepo(t *testing.T) {
|
|||
SortType: "oldest",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 14, len(issues))
|
||||
assert.Len(t, issues, 14)
|
||||
assert.NoError(t, issues[0].LoadDiscussComments())
|
||||
assert.EqualValues(t, 0, len(issues[0].Comments))
|
||||
assert.Empty(t, issues[0].Comments)
|
||||
|
||||
pulls, _, err := models.PullRequests(repo.ID, &models.PullRequestsOptions{
|
||||
SortType: "oldest",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 34, len(pulls))
|
||||
assert.Len(t, pulls, 34)
|
||||
assert.NoError(t, pulls[0].LoadIssue())
|
||||
assert.NoError(t, pulls[0].Issue.LoadDiscussComments())
|
||||
assert.EqualValues(t, 2, len(pulls[0].Issue.Comments))
|
||||
assert.Len(t, pulls[0].Issue.Comments, 2)
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
|
|||
// downloader.GetIssues()
|
||||
issues, isEnd, err := downloader.GetIssues(1, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(issues))
|
||||
assert.Len(t, issues, 2)
|
||||
assert.False(t, isEnd)
|
||||
|
||||
var (
|
||||
|
@ -242,7 +242,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
|
|||
// downloader.GetComments()
|
||||
comments, err := downloader.GetComments(2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(comments))
|
||||
assert.Len(t, comments, 2)
|
||||
assert.EqualValues(t, []*base.Comment{
|
||||
{
|
||||
IssueIndex: 2,
|
||||
|
@ -273,7 +273,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
|
|||
// downloader.GetPullRequests()
|
||||
prs, _, err := downloader.GetPullRequests(1, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(prs))
|
||||
assert.Len(t, prs, 2)
|
||||
|
||||
closed1 = time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)
|
||||
var merged1 = time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)
|
||||
|
|
|
@ -115,7 +115,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
|||
|
||||
issues, isEnd, err := downloader.GetIssues(1, 2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(issues))
|
||||
assert.Len(t, issues, 2)
|
||||
assert.False(t, isEnd)
|
||||
|
||||
var (
|
||||
|
@ -206,7 +206,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
|||
|
||||
comments, err := downloader.GetComments(2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 4, len(comments))
|
||||
assert.Len(t, comments, 4)
|
||||
assert.EqualValues(t, []*base.Comment{
|
||||
{
|
||||
IssueIndex: 2,
|
||||
|
|
|
@ -80,7 +80,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
// downloader.GetIssues()
|
||||
issues, isEnd, err := downloader.GetIssues(1, 8)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(issues))
|
||||
assert.Len(t, issues, 1)
|
||||
assert.False(t, isEnd)
|
||||
|
||||
assert.EqualValues(t, []*base.Issue{
|
||||
|
@ -105,7 +105,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
// downloader.GetComments()
|
||||
comments, err := downloader.GetComments(1)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(comments))
|
||||
assert.Len(t, comments, 1)
|
||||
assert.EqualValues(t, []*base.Comment{
|
||||
{
|
||||
PosterName: "lunny",
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestComplexity_Generate(t *testing.T) {
|
|||
for i := 0; i < maxCount; i++ {
|
||||
pwd, err := Generate(pwdLen)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, pwdLen, len(pwd))
|
||||
assert.Len(t, pwd, pwdLen)
|
||||
assert.True(t, IsComplexEnough(pwd), "Failed complexities with modes %+v for generated: %s", modes, pwd)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestChannelQueue(t *testing.T) {
|
|||
}, &testData{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, queue.(*ChannelQueue).WorkerPool.boostWorkers, 5)
|
||||
assert.Equal(t, 5, queue.(*ChannelQueue).WorkerPool.boostWorkers)
|
||||
|
||||
go queue.Run(nilFn, nilFn)
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
|
|||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 16}).(*models.Repository)
|
||||
payloadCommits, err := pushCommits.ToAPIPayloadCommits(repo.RepoPath(), "/user2/repo16")
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 3, len(payloadCommits))
|
||||
assert.Len(t, payloadCommits, 3)
|
||||
|
||||
assert.Equal(t, "69554a6", payloadCommits[0].ID)
|
||||
assert.Equal(t, "not signed commit", payloadCommits[0].Message)
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
|
|||
team := models.AssertExistsAndLoadBean(t, &models.Team{ID: teamID}).(*models.Team)
|
||||
assert.NoError(t, team.GetRepositories(&models.SearchTeamOptions{}), "%s: GetRepositories", team.Name)
|
||||
assert.Len(t, team.Repos, team.NumRepos, "%s: len repo", team.Name)
|
||||
assert.Equal(t, len(repoIds), len(team.Repos), "%s: repo count", team.Name)
|
||||
assert.Len(t, team.Repos, len(repoIds), "%s: repo count", team.Name)
|
||||
for i, rid := range repoIds {
|
||||
if rid > 0 {
|
||||
assert.True(t, team.HasRepository(rid), "%s: HasRepository(%d) %d", rid, i)
|
||||
|
|
|
@ -64,7 +64,7 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas interface{}) {
|
|||
if !assert.True(t, ok) {
|
||||
return
|
||||
}
|
||||
if !assert.EqualValues(t, len(expectedNames), len(pageMetas)) {
|
||||
if !assert.Len(t, pageMetas, len(expectedNames)) {
|
||||
return
|
||||
}
|
||||
for i, pageMeta := range pageMetas {
|
||||
|
|
|
@ -33,9 +33,9 @@ func TestArchivedIssues(t *testing.T) {
|
|||
IsArchived[repo.ID] = repo.IsArchived
|
||||
NumIssues[repo.ID] = repo.NumIssues
|
||||
}
|
||||
assert.EqualValues(t, false, IsArchived[50])
|
||||
assert.False(t, IsArchived[50])
|
||||
assert.EqualValues(t, 1, NumIssues[50])
|
||||
assert.EqualValues(t, true, IsArchived[51])
|
||||
assert.True(t, IsArchived[51])
|
||||
assert.EqualValues(t, 1, NumIssues[51])
|
||||
|
||||
// Act
|
||||
|
|
|
@ -35,7 +35,7 @@ func waitForCount(t *testing.T, num int) {
|
|||
}
|
||||
}
|
||||
|
||||
assert.Equal(t, num, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, num)
|
||||
}
|
||||
|
||||
func releaseOneEntry(t *testing.T, inFlight []*ArchiveRequest) {
|
||||
|
@ -128,7 +128,7 @@ func TestArchive_Basic(t *testing.T) {
|
|||
|
||||
// Sleep two seconds to make sure the queue doesn't change.
|
||||
time.Sleep(2 * time.Second)
|
||||
assert.Equal(t, 3, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, 3)
|
||||
|
||||
// Release them all, they'll then stall at the archiveQueueReleaseCond while
|
||||
// we examine the queue state.
|
||||
|
@ -160,7 +160,7 @@ func TestArchive_Basic(t *testing.T) {
|
|||
|
||||
// Queues should not have drained yet, because we haven't released them.
|
||||
// Do so now.
|
||||
assert.Equal(t, 3, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, 3)
|
||||
|
||||
zipReq2 := DeriveRequestFrom(ctx, firstCommit+".zip")
|
||||
// This zipReq should match what's sitting in the queue, as we haven't
|
||||
|
@ -174,15 +174,15 @@ func TestArchive_Basic(t *testing.T) {
|
|||
ArchiveRepository(zipReq2)
|
||||
|
||||
// Make sure the queue hasn't grown any.
|
||||
assert.Equal(t, 3, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, 3)
|
||||
|
||||
// Make sure the queue drains properly
|
||||
releaseOneEntry(t, inFlight)
|
||||
assert.Equal(t, 2, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, 2)
|
||||
releaseOneEntry(t, inFlight)
|
||||
assert.Equal(t, 1, len(archiveInProgress))
|
||||
assert.Len(t, archiveInProgress, 1)
|
||||
releaseOneEntry(t, inFlight)
|
||||
assert.Equal(t, 0, len(archiveInProgress))
|
||||
assert.Empty(t, archiveInProgress)
|
||||
|
||||
// Now we'll submit a request and TimedWaitForCompletion twice, before and
|
||||
// after we release it. We should trigger both the timeout and non-timeout
|
||||
|
@ -194,8 +194,8 @@ func TestArchive_Basic(t *testing.T) {
|
|||
|
||||
// Guaranteed to timeout; we haven't signalled the request to start..
|
||||
completed, timedout = timedReq.TimedWaitForCompletion(ctx, 2*time.Second)
|
||||
assert.Equal(t, false, completed)
|
||||
assert.Equal(t, true, timedout)
|
||||
assert.False(t, completed)
|
||||
assert.True(t, timedout)
|
||||
|
||||
queueMutex.Lock()
|
||||
archiveQueueStartCond.Broadcast()
|
||||
|
@ -203,8 +203,8 @@ func TestArchive_Basic(t *testing.T) {
|
|||
|
||||
// Shouldn't timeout, we've now signalled it and it's a small request.
|
||||
completed, timedout = timedReq.TimedWaitForCompletion(ctx, 15*time.Second)
|
||||
assert.Equal(t, true, completed)
|
||||
assert.Equal(t, false, timedout)
|
||||
assert.True(t, completed)
|
||||
assert.False(t, timedout)
|
||||
|
||||
zipReq2 = DeriveRequestFrom(ctx, firstCommit+".zip")
|
||||
// Now, we're guaranteed to have released the original zipReq from the queue.
|
||||
|
|
|
@ -110,13 +110,13 @@ func TestCSVDiff(t *testing.T) {
|
|||
|
||||
result, err := CreateCsvDiff(diff.Files[0], baseReader, headReader)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(result), "case %d: should be one section", n)
|
||||
assert.Len(t, result, 1, "case %d: should be one section", n)
|
||||
|
||||
section := result[0]
|
||||
assert.Equal(t, len(c.cells), len(section.Rows), "case %d: should be %d rows", n, len(c.cells))
|
||||
assert.Len(t, section.Rows, len(c.cells), "case %d: should be %d rows", n, len(c.cells))
|
||||
|
||||
for i, row := range section.Rows {
|
||||
assert.Equal(t, 2, len(row.Cells), "case %d: row %d should have two cells", n, i)
|
||||
assert.Len(t, row.Cells, 2, "case %d: row %d should have two cells", n, i)
|
||||
for j, cell := range row.Cells {
|
||||
assert.Equal(t, c.cells[i][j], cell.Type, "case %d: row %d cell %d should be equal", n, i, j)
|
||||
}
|
||||
|
|
|
@ -33,5 +33,5 @@ func TestDeleteNotPassedAssignee(t *testing.T) {
|
|||
// Check they're gone
|
||||
assignees, err := models.GetAssigneesByIssue(issue)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(assignees))
|
||||
assert.Empty(t, assignees)
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ func TestRelease_Update(t *testing.T) {
|
|||
|
||||
assert.NoError(t, UpdateRelease(user, gitRepo, release, []string{attach.UUID}, nil, nil))
|
||||
assert.NoError(t, models.GetReleaseAttachments(release))
|
||||
assert.EqualValues(t, 1, len(release.Attachments))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
|
||||
|
@ -232,7 +232,7 @@ func TestRelease_Update(t *testing.T) {
|
|||
}))
|
||||
release.Attachments = nil
|
||||
assert.NoError(t, models.GetReleaseAttachments(release))
|
||||
assert.EqualValues(t, 1, len(release.Attachments))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, "test2.txt", release.Attachments[0].Name)
|
||||
|
@ -241,7 +241,7 @@ func TestRelease_Update(t *testing.T) {
|
|||
assert.NoError(t, UpdateRelease(user, gitRepo, release, nil, []string{attach.UUID}, nil))
|
||||
release.Attachments = nil
|
||||
assert.NoError(t, models.GetReleaseAttachments(release))
|
||||
assert.EqualValues(t, 0, len(release.Attachments))
|
||||
assert.Empty(t, release.Attachments)
|
||||
}
|
||||
|
||||
func TestRelease_createTag(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue