mirror of
https://github.com/go-gitea/gitea
synced 2025-07-29 05:38:37 +00:00
Enable testifylint rules (#34075)
enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
This commit is contained in:
@@ -217,7 +217,7 @@ func TestAPIEditUser(t *testing.T) {
|
||||
|
||||
errMap := make(map[string]any)
|
||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||
assert.EqualValues(t, "e-mail invalid [email: ]", errMap["message"].(string))
|
||||
assert.Equal(t, "e-mail invalid [email: ]", errMap["message"].(string))
|
||||
|
||||
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
||||
assert.False(t, user2.IsRestricted)
|
||||
|
@@ -24,13 +24,13 @@ func testAPIGetBranch(t *testing.T, branchName string, exists bool) {
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, NoExpectedStatus)
|
||||
if !exists {
|
||||
assert.EqualValues(t, http.StatusNotFound, resp.Code)
|
||||
assert.Equal(t, http.StatusNotFound, resp.Code)
|
||||
return
|
||||
}
|
||||
assert.EqualValues(t, http.StatusOK, resp.Code)
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
var branch api.Branch
|
||||
DecodeJSON(t, resp, &branch)
|
||||
assert.EqualValues(t, branchName, branch.Name)
|
||||
assert.Equal(t, branchName, branch.Name)
|
||||
assert.True(t, branch.UserCanPush)
|
||||
assert.True(t, branch.UserCanMerge)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func testAPIGetBranchProtection(t *testing.T, branchName string, expectedHTTPSta
|
||||
if resp.Code == http.StatusOK {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.RuleName)
|
||||
assert.Equal(t, branchName, branchProtection.RuleName)
|
||||
return &branchProtection
|
||||
}
|
||||
return nil
|
||||
@@ -60,7 +60,7 @@ func testAPICreateBranchProtection(t *testing.T, branchName string, expectedPrio
|
||||
if resp.Code == http.StatusCreated {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.RuleName)
|
||||
assert.Equal(t, branchName, branchProtection.RuleName)
|
||||
assert.EqualValues(t, expectedPriority, branchProtection.Priority)
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func testAPIEditBranchProtection(t *testing.T, branchName string, body *api.Bran
|
||||
if resp.Code == http.StatusOK {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.RuleName)
|
||||
assert.Equal(t, branchName, branchProtection.RuleName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func testAPICreateBranch(t testing.TB, session *TestSession, user, repo, oldBran
|
||||
DecodeJSON(t, resp, &branch)
|
||||
|
||||
if resp.Result().StatusCode == http.StatusCreated {
|
||||
assert.EqualValues(t, newBranch, branch.Name)
|
||||
assert.Equal(t, newBranch, branch.Name)
|
||||
}
|
||||
|
||||
return resp.Result().StatusCode == status
|
||||
|
@@ -106,7 +106,7 @@ func TestAPICreateComment(t *testing.T) {
|
||||
|
||||
var updatedComment api.Comment
|
||||
DecodeJSON(t, resp, &updatedComment)
|
||||
assert.EqualValues(t, commentBody, updatedComment.Body)
|
||||
assert.Equal(t, commentBody, updatedComment.Body)
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: updatedComment.ID, IssueID: issue.ID, Content: commentBody})
|
||||
|
||||
t.Run("BlockedByRepoOwner", func(t *testing.T) {
|
||||
@@ -233,8 +233,8 @@ func TestAPIEditComment(t *testing.T) {
|
||||
|
||||
var updatedComment api.Comment
|
||||
DecodeJSON(t, resp, &updatedComment)
|
||||
assert.EqualValues(t, comment.ID, updatedComment.ID)
|
||||
assert.EqualValues(t, newCommentBody, updatedComment.Body)
|
||||
assert.Equal(t, comment.ID, updatedComment.ID)
|
||||
assert.Equal(t, newCommentBody, updatedComment.Body)
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: comment.ID, IssueID: issue.ID, Content: newCommentBody})
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ func TestAPIForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
|
||||
// fork into a limited org
|
||||
limitedOrg := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 22})
|
||||
assert.EqualValues(t, api.VisibleTypeLimited, limitedOrg.Visibility)
|
||||
assert.Equal(t, api.VisibleTypeLimited, limitedOrg.Visibility)
|
||||
|
||||
ownerTeam1, err := org_model.OrgFromUser(limitedOrg).GetOwnerTeam(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
@@ -49,7 +49,7 @@ func TestAPIForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
user4Sess := loginUser(t, "user4")
|
||||
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user4"})
|
||||
privateOrg := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 23})
|
||||
assert.EqualValues(t, api.VisibleTypePrivate, privateOrg.Visibility)
|
||||
assert.Equal(t, api.VisibleTypePrivate, privateOrg.Visibility)
|
||||
|
||||
ownerTeam2, err := org_model.OrgFromUser(privateOrg).GetOwnerTeam(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
@@ -70,7 +70,7 @@ func TestAPIForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
DecodeJSON(t, resp, &forks)
|
||||
|
||||
assert.Empty(t, forks)
|
||||
assert.EqualValues(t, "0", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "0", resp.Header().Get("X-Total-Count"))
|
||||
})
|
||||
|
||||
t.Run("Logged in", func(t *testing.T) {
|
||||
@@ -83,7 +83,7 @@ func TestAPIForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
DecodeJSON(t, resp, &forks)
|
||||
|
||||
assert.Len(t, forks, 2)
|
||||
assert.EqualValues(t, "2", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "2", resp.Header().Get("X-Total-Count"))
|
||||
|
||||
assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam2, user1))
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestAPIForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
DecodeJSON(t, resp, &forks)
|
||||
|
||||
assert.Len(t, forks, 2)
|
||||
assert.EqualValues(t, "2", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "2", resp.Header().Get("X-Total-Count"))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestGetPrivateReposForks(t *testing.T) {
|
||||
forks := []*api.Repository{}
|
||||
DecodeJSON(t, resp, &forks)
|
||||
assert.Len(t, forks, 1)
|
||||
assert.EqualValues(t, "1", resp.Header().Get("X-Total-Count"))
|
||||
assert.EqualValues(t, "forked-repo", forks[0].Name)
|
||||
assert.EqualValues(t, privateOrg.Name, forks[0].Owner.UserName)
|
||||
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "forked-repo", forks[0].Name)
|
||||
assert.Equal(t, privateOrg.Name, forks[0].Owner.UserName)
|
||||
}
|
||||
|
@@ -86,13 +86,13 @@ func TestGPGKeys(t *testing.T) {
|
||||
assert.Len(t, keys, 1)
|
||||
|
||||
primaryKey1 := keys[0] // Primary key 1
|
||||
assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID)
|
||||
assert.Equal(t, "38EA3BCED732982C", primaryKey1.KeyID)
|
||||
assert.Len(t, primaryKey1.Emails, 1)
|
||||
assert.EqualValues(t, "user2@example.com", primaryKey1.Emails[0].Email)
|
||||
assert.Equal(t, "user2@example.com", primaryKey1.Emails[0].Email)
|
||||
assert.True(t, primaryKey1.Emails[0].Verified)
|
||||
|
||||
subKey := primaryKey1.SubsKey[0] // Subkey of 38EA3BCED732982C
|
||||
assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID)
|
||||
assert.Equal(t, "70D7C694D17D03AD", subKey.KeyID)
|
||||
assert.Empty(t, subKey.Emails)
|
||||
|
||||
var key api.GPGKey
|
||||
@@ -100,16 +100,16 @@ func TestGPGKeys(t *testing.T) {
|
||||
AddTokenAuth(tokenWithGPGKeyScope)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &key)
|
||||
assert.EqualValues(t, "38EA3BCED732982C", key.KeyID)
|
||||
assert.Equal(t, "38EA3BCED732982C", key.KeyID)
|
||||
assert.Len(t, key.Emails, 1)
|
||||
assert.EqualValues(t, "user2@example.com", key.Emails[0].Email)
|
||||
assert.Equal(t, "user2@example.com", key.Emails[0].Email)
|
||||
assert.True(t, key.Emails[0].Verified)
|
||||
|
||||
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)). // Subkey of 38EA3BCED732982C
|
||||
AddTokenAuth(tokenWithGPGKeyScope)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &key)
|
||||
assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID)
|
||||
assert.Equal(t, "70D7C694D17D03AD", key.KeyID)
|
||||
assert.Empty(t, key.Emails)
|
||||
})
|
||||
|
||||
|
@@ -276,7 +276,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
|
||||
}
|
||||
err := api.APIError{}
|
||||
DecodeJSON(t, resp, &err)
|
||||
assert.EqualValues(t, "Please try again later", err.Message)
|
||||
assert.Equal(t, "Please try again later", err.Message)
|
||||
queue.GetManager().FlushAll(t.Context(), 5*time.Second)
|
||||
<-time.After(1 * time.Second)
|
||||
}
|
||||
@@ -286,7 +286,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
|
||||
expected = http.StatusOK
|
||||
}
|
||||
|
||||
if !assert.EqualValues(t, expected, resp.Code,
|
||||
if !assert.Equal(t, expected, resp.Code,
|
||||
"Request: %s %s", req.Method, req.URL.String()) {
|
||||
logUnexpectedResponse(t, resp)
|
||||
}
|
||||
|
@@ -38,8 +38,8 @@ func TestAPIModifyLabels(t *testing.T) {
|
||||
apiLabel := new(api.Label)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, RepoID: repo.ID})
|
||||
assert.EqualValues(t, dbLabel.Name, apiLabel.Name)
|
||||
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
assert.Equal(t, dbLabel.Name, apiLabel.Name)
|
||||
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
|
||||
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
|
||||
Name: "TestL 2",
|
||||
@@ -67,7 +67,7 @@ func TestAPIModifyLabels(t *testing.T) {
|
||||
AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
|
||||
// EditLabel
|
||||
newName := "LabelNewName"
|
||||
@@ -79,7 +79,7 @@ func TestAPIModifyLabels(t *testing.T) {
|
||||
}).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
assert.EqualValues(t, newColor, apiLabel.Color)
|
||||
assert.Equal(t, newColor, apiLabel.Color)
|
||||
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
|
||||
Color: &newColorWrong,
|
||||
}).AddTokenAuth(token)
|
||||
@@ -165,7 +165,7 @@ func TestAPIReplaceIssueLabels(t *testing.T) {
|
||||
var apiLabels []*api.Label
|
||||
DecodeJSON(t, resp, &apiLabels)
|
||||
if assert.Len(t, apiLabels, 1) {
|
||||
assert.EqualValues(t, label.ID, apiLabels[0].ID)
|
||||
assert.Equal(t, label.ID, apiLabels[0].ID)
|
||||
}
|
||||
|
||||
unittest.AssertCount(t, &issues_model.IssueLabel{IssueID: issue.ID}, 1)
|
||||
@@ -191,7 +191,7 @@ func TestAPIReplaceIssueLabelsWithLabelNames(t *testing.T) {
|
||||
var apiLabels []*api.Label
|
||||
DecodeJSON(t, resp, &apiLabels)
|
||||
if assert.Len(t, apiLabels, 1) {
|
||||
assert.EqualValues(t, label.Name, apiLabels[0].Name)
|
||||
assert.Equal(t, label.Name, apiLabels[0].Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ func TestAPIModifyOrgLabels(t *testing.T) {
|
||||
apiLabel := new(api.Label)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, OrgID: owner.ID})
|
||||
assert.EqualValues(t, dbLabel.Name, apiLabel.Name)
|
||||
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
assert.Equal(t, dbLabel.Name, apiLabel.Name)
|
||||
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
|
||||
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
|
||||
Name: "TestL 2",
|
||||
@@ -244,7 +244,7 @@ func TestAPIModifyOrgLabels(t *testing.T) {
|
||||
AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
|
||||
|
||||
// EditLabel
|
||||
newName := "LabelNewName"
|
||||
@@ -256,7 +256,7 @@ func TestAPIModifyOrgLabels(t *testing.T) {
|
||||
}).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiLabel)
|
||||
assert.EqualValues(t, newColor, apiLabel.Color)
|
||||
assert.Equal(t, newColor, apiLabel.Color)
|
||||
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
|
||||
Color: &newColorWrong,
|
||||
}).AddTokenAuth(token)
|
||||
|
@@ -73,7 +73,7 @@ func TestAPIIssuesMilestone(t *testing.T) {
|
||||
AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiMilestone)
|
||||
assert.EqualValues(t, apiMilestones[2], apiMilestone)
|
||||
assert.Equal(t, apiMilestones[2], apiMilestone)
|
||||
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones?state=%s&name=%s", owner.Name, repo.Name, "all", "milestone2")).
|
||||
AddTokenAuth(token)
|
||||
|
@@ -35,11 +35,11 @@ func TestAPIListStopWatches(t *testing.T) {
|
||||
stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID})
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: stopwatch.IssueID})
|
||||
if assert.Len(t, apiWatches, 1) {
|
||||
assert.EqualValues(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
|
||||
assert.EqualValues(t, issue.Index, apiWatches[0].IssueIndex)
|
||||
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Equal(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
|
||||
assert.Equal(t, issue.Index, apiWatches[0].IssueIndex)
|
||||
assert.Equal(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.Equal(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.Equal(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
@@ -43,11 +43,11 @@ func TestAPIIssueSubscriptions(t *testing.T) {
|
||||
wi := new(api.WatchInfo)
|
||||
DecodeJSON(t, resp, wi)
|
||||
|
||||
assert.EqualValues(t, isWatching, wi.Subscribed)
|
||||
assert.EqualValues(t, !isWatching, wi.Ignored)
|
||||
assert.EqualValues(t, issue.APIURL(db.DefaultContext)+"/subscriptions", wi.URL)
|
||||
assert.Equal(t, isWatching, wi.Subscribed)
|
||||
assert.Equal(t, !isWatching, wi.Ignored)
|
||||
assert.Equal(t, issue.APIURL(db.DefaultContext)+"/subscriptions", wi.URL)
|
||||
assert.EqualValues(t, issue.CreatedUnix, wi.CreatedAt.Unix())
|
||||
assert.EqualValues(t, issueRepo.APIURL(), wi.RepositoryURL)
|
||||
assert.Equal(t, issueRepo.APIURL(), wi.RepositoryURL)
|
||||
}
|
||||
|
||||
testSubscription(issue1, true)
|
||||
|
@@ -313,7 +313,7 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
req = NewRequest(t, "GET", link.String()).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 20)
|
||||
|
||||
query.Add("limit", "10")
|
||||
@@ -321,7 +321,7 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
req = NewRequest(t, "GET", link.String()).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 10)
|
||||
|
||||
query = url.Values{"assigned": {"true"}, "state": {"all"}}
|
||||
|
@@ -41,8 +41,8 @@ func TestAPIGetTrackedTimes(t *testing.T) {
|
||||
|
||||
for i, time := range expect {
|
||||
assert.Equal(t, time.ID, apiTimes[i].ID)
|
||||
assert.EqualValues(t, issue2.Title, apiTimes[i].Issue.Title)
|
||||
assert.EqualValues(t, issue2.ID, apiTimes[i].IssueID)
|
||||
assert.Equal(t, issue2.Title, apiTimes[i].Issue.Title)
|
||||
assert.Equal(t, issue2.ID, apiTimes[i].IssueID)
|
||||
assert.Equal(t, time.Created.Unix(), apiTimes[i].Created.Unix())
|
||||
assert.Equal(t, time.Time, apiTimes[i].Time)
|
||||
user, err := user_model.GetUserByID(db.DefaultContext, time.UserID)
|
||||
@@ -125,6 +125,6 @@ func TestAPIAddTrackedTimes(t *testing.T) {
|
||||
DecodeJSON(t, resp, &apiNewTime)
|
||||
|
||||
assert.EqualValues(t, 33, apiNewTime.Time)
|
||||
assert.EqualValues(t, user2.ID, apiNewTime.UserID)
|
||||
assert.Equal(t, user2.ID, apiNewTime.UserID)
|
||||
assert.EqualValues(t, 947688818, apiNewTime.Created.Unix())
|
||||
}
|
||||
|
@@ -104,10 +104,10 @@ func TestAPINotification(t *testing.T) {
|
||||
assert.EqualValues(t, 5, apiN.ID)
|
||||
assert.False(t, apiN.Pinned)
|
||||
assert.True(t, apiN.Unread)
|
||||
assert.EqualValues(t, "issue4", apiN.Subject.Title)
|
||||
assert.Equal(t, "issue4", apiN.Subject.Title)
|
||||
assert.EqualValues(t, "Issue", apiN.Subject.Type)
|
||||
assert.EqualValues(t, thread5.Issue.APIURL(db.DefaultContext), apiN.Subject.URL)
|
||||
assert.EqualValues(t, thread5.Repository.HTMLURL(), apiN.Repository.HTMLURL)
|
||||
assert.Equal(t, thread5.Issue.APIURL(db.DefaultContext), apiN.Subject.URL)
|
||||
assert.Equal(t, thread5.Repository.HTMLURL(), apiN.Repository.HTMLURL)
|
||||
|
||||
MakeRequest(t, NewRequest(t, "GET", "/api/v1/notifications/new"), http.StatusUnauthorized)
|
||||
|
||||
|
@@ -43,12 +43,12 @@ func testAPICreateOAuth2Application(t *testing.T) {
|
||||
var createdApp *api.OAuth2Application
|
||||
DecodeJSON(t, resp, &createdApp)
|
||||
|
||||
assert.EqualValues(t, appBody.Name, createdApp.Name)
|
||||
assert.Equal(t, appBody.Name, createdApp.Name)
|
||||
assert.Len(t, createdApp.ClientSecret, 56)
|
||||
assert.Len(t, createdApp.ClientID, 36)
|
||||
assert.True(t, createdApp.ConfidentialClient)
|
||||
assert.NotEmpty(t, createdApp.Created)
|
||||
assert.EqualValues(t, appBody.RedirectURIs[0], createdApp.RedirectURIs[0])
|
||||
assert.Equal(t, appBody.RedirectURIs[0], createdApp.RedirectURIs[0])
|
||||
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{UID: user.ID, Name: createdApp.Name})
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ func testAPIListOAuth2Applications(t *testing.T) {
|
||||
DecodeJSON(t, resp, &appList)
|
||||
expectedApp := appList[0]
|
||||
|
||||
assert.EqualValues(t, expectedApp.Name, existApp.Name)
|
||||
assert.EqualValues(t, expectedApp.ClientID, existApp.ClientID)
|
||||
assert.Equal(t, expectedApp.Name, existApp.Name)
|
||||
assert.Equal(t, expectedApp.ClientID, existApp.ClientID)
|
||||
assert.Equal(t, expectedApp.ConfidentialClient, existApp.ConfidentialClient)
|
||||
assert.Len(t, expectedApp.ClientID, 36)
|
||||
assert.Empty(t, expectedApp.ClientSecret)
|
||||
assert.EqualValues(t, existApp.RedirectURIs[0], expectedApp.RedirectURIs[0])
|
||||
assert.Equal(t, existApp.RedirectURIs[0], expectedApp.RedirectURIs[0])
|
||||
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
|
||||
}
|
||||
|
||||
@@ -128,13 +128,13 @@ func testAPIGetOAuth2Application(t *testing.T) {
|
||||
DecodeJSON(t, resp, &app)
|
||||
expectedApp := app
|
||||
|
||||
assert.EqualValues(t, expectedApp.Name, existApp.Name)
|
||||
assert.EqualValues(t, expectedApp.ClientID, existApp.ClientID)
|
||||
assert.Equal(t, expectedApp.Name, existApp.Name)
|
||||
assert.Equal(t, expectedApp.ClientID, existApp.ClientID)
|
||||
assert.Equal(t, expectedApp.ConfidentialClient, existApp.ConfidentialClient)
|
||||
assert.Len(t, expectedApp.ClientID, 36)
|
||||
assert.Empty(t, expectedApp.ClientSecret)
|
||||
assert.Len(t, expectedApp.RedirectURIs, 1)
|
||||
assert.EqualValues(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
|
||||
assert.Equal(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
|
||||
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ func testAPIUpdateOAuth2Application(t *testing.T) {
|
||||
expectedApp := app
|
||||
|
||||
assert.Len(t, expectedApp.RedirectURIs, 2)
|
||||
assert.EqualValues(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0])
|
||||
assert.EqualValues(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1])
|
||||
assert.Equal(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0])
|
||||
assert.Equal(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1])
|
||||
assert.Equal(t, expectedApp.ConfidentialClient, appBody.ConfidentialClient)
|
||||
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ func TestAPIOrgCreateRename(t *testing.T) {
|
||||
req = NewRequestf(t, "GET", "/api/v1/orgs/%s", org.UserName).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiOrg)
|
||||
assert.EqualValues(t, org.UserName, apiOrg.Name)
|
||||
assert.Equal(t, org.UserName, apiOrg.Name)
|
||||
|
||||
t.Run("CheckPermission", func(t *testing.T) {
|
||||
// Check owner team permission
|
||||
@@ -86,7 +86,7 @@ func TestAPIOrgCreateRename(t *testing.T) {
|
||||
var users []*api.User
|
||||
DecodeJSON(t, resp, &users)
|
||||
assert.Len(t, users, 1)
|
||||
assert.EqualValues(t, "user1", users[0].UserName)
|
||||
assert.Equal(t, "user1", users[0].UserName)
|
||||
})
|
||||
|
||||
t.Run("RenameOrg", func(t *testing.T) {
|
||||
@@ -225,6 +225,6 @@ func TestAPIOrgSearchEmptyTeam(t *testing.T) {
|
||||
DecodeJSON(t, resp, &data)
|
||||
assert.True(t, data.Ok)
|
||||
if assert.Len(t, data.Data, 1) {
|
||||
assert.EqualValues(t, "Empty", data.Data[0].Name)
|
||||
assert.Equal(t, "Empty", data.Data[0].Name)
|
||||
}
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ func TestPackageConan(t *testing.T) {
|
||||
|
||||
assert.Equal(t, int64(len(contentConaninfo)), pb.Size)
|
||||
} else {
|
||||
assert.FailNow(t, "unknown file: %s", pf.Name)
|
||||
assert.FailNow(t, "unknown file", "unknown file: %s", pf.Name)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@@ -441,7 +441,7 @@ func TestPackageContainer(t *testing.T) {
|
||||
assert.Equal(t, "application/vnd.docker.image.rootfs.diff.tar.gzip", pfd.Properties.GetByName(container_module.PropertyMediaType))
|
||||
assert.Equal(t, blobDigest, pfd.Properties.GetByName(container_module.PropertyDigest))
|
||||
default:
|
||||
assert.FailNow(t, "unknown file: %s", pfd.File.Name)
|
||||
assert.FailNow(t, "unknown file", "unknown file: %s", pfd.File.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -276,7 +276,7 @@ func TestPackageNuGet(t *testing.T) {
|
||||
case fmt.Sprintf("%s.nuspec", packageName):
|
||||
assert.False(t, pf.IsLead)
|
||||
default:
|
||||
assert.Fail(t, "unexpected filename: %v", pf.Name)
|
||||
assert.Fail(t, "unexpected filename", "unexpected filename: %v", pf.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ func TestPackageNuGet(t *testing.T) {
|
||||
case fmt.Sprintf("%s.nuspec", packageName):
|
||||
assert.False(t, pf.IsLead)
|
||||
default:
|
||||
assert.Fail(t, "unexpected filename: %v", pf.Name)
|
||||
assert.Fail(t, "unexpected filename", "unexpected filename: %v", pf.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
|
||||
assert.Equal(t, nuget_module.PropertySymbolID, pps[0].Name)
|
||||
assert.Equal(t, symbolID, pps[0].Value)
|
||||
default:
|
||||
assert.FailNow(t, "unexpected file: %v", pf.Name)
|
||||
assert.FailNow(t, "unexpected file", "unexpected file: %v", pf.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -317,7 +317,7 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`,
|
||||
var result Metadata
|
||||
decodeGzipXML(t, resp, &result)
|
||||
|
||||
assert.EqualValues(t, 1, result.PackageCount)
|
||||
assert.Equal(t, 1, result.PackageCount)
|
||||
assert.Len(t, result.Packages, 1)
|
||||
p := result.Packages[0]
|
||||
assert.Equal(t, "rpm", p.Type)
|
||||
@@ -366,7 +366,7 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`,
|
||||
var result Filelists
|
||||
decodeGzipXML(t, resp, &result)
|
||||
|
||||
assert.EqualValues(t, 1, result.PackageCount)
|
||||
assert.Equal(t, 1, result.PackageCount)
|
||||
assert.Len(t, result.Packages, 1)
|
||||
p := result.Packages[0]
|
||||
assert.NotEmpty(t, p.Pkgid)
|
||||
@@ -403,7 +403,7 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`,
|
||||
var result Other
|
||||
decodeGzipXML(t, resp, &result)
|
||||
|
||||
assert.EqualValues(t, 1, result.PackageCount)
|
||||
assert.Equal(t, 1, result.PackageCount)
|
||||
assert.Len(t, result.Packages, 1)
|
||||
p := result.Packages[0]
|
||||
assert.NotEmpty(t, p.Pkgid)
|
||||
|
@@ -116,7 +116,7 @@ func TestPackageAPI(t *testing.T) {
|
||||
var ap2 *api.Package
|
||||
DecodeJSON(t, resp, &ap2)
|
||||
assert.NotNil(t, ap2.Repository)
|
||||
assert.EqualValues(t, newRepo.ID, ap2.Repository.ID)
|
||||
assert.Equal(t, newRepo.ID, ap2.Repository.ID)
|
||||
|
||||
// link to repository without write access, should fail
|
||||
req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/packages/%s/generic/%s/-/link/%s", user.Name, packageName, "repo3")).AddTokenAuth(tokenWritePackage)
|
||||
|
@@ -43,17 +43,17 @@ func TestAPIPullReview(t *testing.T) {
|
||||
require.Len(t, reviews, 8)
|
||||
|
||||
for _, r := range reviews {
|
||||
assert.EqualValues(t, pullIssue.HTMLURL(), r.HTMLPullURL)
|
||||
assert.Equal(t, pullIssue.HTMLURL(), r.HTMLPullURL)
|
||||
}
|
||||
assert.EqualValues(t, 8, reviews[3].ID)
|
||||
assert.EqualValues(t, "APPROVED", reviews[3].State)
|
||||
assert.EqualValues(t, 0, reviews[3].CodeCommentsCount)
|
||||
assert.Equal(t, 0, reviews[3].CodeCommentsCount)
|
||||
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.Equal(t, 1, reviews[5].CodeCommentsCount)
|
||||
assert.EqualValues(t, -1, reviews[5].Reviewer.ID) // ghost user
|
||||
assert.False(t, reviews[5].Stale)
|
||||
assert.True(t, reviews[5].Official)
|
||||
@@ -64,13 +64,13 @@ func TestAPIPullReview(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
var review api.PullReview
|
||||
DecodeJSON(t, resp, &review)
|
||||
assert.EqualValues(t, *reviews[3], review)
|
||||
assert.Equal(t, *reviews[3], review)
|
||||
|
||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, reviews[5].ID).
|
||||
AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &review)
|
||||
assert.EqualValues(t, *reviews[5], review)
|
||||
assert.Equal(t, *reviews[5], review)
|
||||
|
||||
// test GetPullReviewComments
|
||||
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 7})
|
||||
@@ -80,11 +80,11 @@ func TestAPIPullReview(t *testing.T) {
|
||||
var reviewComments []*api.PullReviewComment
|
||||
DecodeJSON(t, resp, &reviewComments)
|
||||
assert.Len(t, reviewComments, 1)
|
||||
assert.EqualValues(t, "Ghost", reviewComments[0].Poster.UserName)
|
||||
assert.EqualValues(t, "a review from a deleted user", reviewComments[0].Body)
|
||||
assert.EqualValues(t, comment.ID, reviewComments[0].ID)
|
||||
assert.Equal(t, "Ghost", reviewComments[0].Poster.UserName)
|
||||
assert.Equal(t, "a review from a deleted user", reviewComments[0].Body)
|
||||
assert.Equal(t, comment.ID, reviewComments[0].ID)
|
||||
assert.EqualValues(t, comment.UpdatedUnix, reviewComments[0].Updated.Unix())
|
||||
assert.EqualValues(t, comment.HTMLURL(db.DefaultContext), reviewComments[0].HTMLURL)
|
||||
assert.Equal(t, comment.HTMLURL(db.DefaultContext), reviewComments[0].HTMLURL)
|
||||
|
||||
// test CreatePullReview
|
||||
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews", repo.OwnerName, repo.Name, pullIssue.Index), &api.CreatePullReviewOptions{
|
||||
@@ -113,7 +113,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||
DecodeJSON(t, resp, &review)
|
||||
assert.EqualValues(t, 6, review.ID)
|
||||
assert.EqualValues(t, "PENDING", review.State)
|
||||
assert.EqualValues(t, 3, review.CodeCommentsCount)
|
||||
assert.Equal(t, 3, review.CodeCommentsCount)
|
||||
|
||||
// test SubmitPullReview
|
||||
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, review.ID), &api.SubmitPullReviewOptions{
|
||||
@@ -124,7 +124,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||
DecodeJSON(t, resp, &review)
|
||||
assert.EqualValues(t, 6, review.ID)
|
||||
assert.EqualValues(t, "APPROVED", review.State)
|
||||
assert.EqualValues(t, 3, review.CodeCommentsCount)
|
||||
assert.Equal(t, 3, review.CodeCommentsCount)
|
||||
|
||||
// test dismiss review
|
||||
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/dismissals", repo.OwnerName, repo.Name, pullIssue.Index, review.ID), &api.DismissPullReviewOptions{
|
||||
@@ -151,7 +151,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &review)
|
||||
assert.EqualValues(t, "COMMENT", review.State)
|
||||
assert.EqualValues(t, 0, review.CodeCommentsCount)
|
||||
assert.Equal(t, 0, review.CodeCommentsCount)
|
||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, review.ID).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNoContent)
|
||||
@@ -179,7 +179,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &commentReview)
|
||||
assert.EqualValues(t, "COMMENT", commentReview.State)
|
||||
assert.EqualValues(t, 2, commentReview.CodeCommentsCount)
|
||||
assert.Equal(t, 2, commentReview.CodeCommentsCount)
|
||||
assert.Empty(t, commentReview.Body)
|
||||
assert.False(t, commentReview.Dismissed)
|
||||
|
||||
@@ -194,8 +194,8 @@ func TestAPIPullReview(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &commentReview)
|
||||
assert.EqualValues(t, "COMMENT", commentReview.State)
|
||||
assert.EqualValues(t, 0, commentReview.CodeCommentsCount)
|
||||
assert.EqualValues(t, commentBody, commentReview.Body)
|
||||
assert.Equal(t, 0, commentReview.CodeCommentsCount)
|
||||
assert.Equal(t, commentBody, commentReview.Body)
|
||||
assert.False(t, commentReview.Dismissed)
|
||||
|
||||
// test CreatePullReview Comment without body and no comments
|
||||
@@ -207,7 +207,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
errMap := make(map[string]any)
|
||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
|
||||
assert.Equal(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
|
||||
|
||||
// test get review requests
|
||||
// to make it simple, use same api with get review
|
||||
@@ -221,14 +221,14 @@ func TestAPIPullReview(t *testing.T) {
|
||||
DecodeJSON(t, resp, &reviews)
|
||||
assert.EqualValues(t, 11, reviews[0].ID)
|
||||
assert.EqualValues(t, "REQUEST_REVIEW", reviews[0].State)
|
||||
assert.EqualValues(t, 0, reviews[0].CodeCommentsCount)
|
||||
assert.Equal(t, 0, reviews[0].CodeCommentsCount)
|
||||
assert.False(t, reviews[0].Stale)
|
||||
assert.True(t, reviews[0].Official)
|
||||
assert.EqualValues(t, "test_team", reviews[0].ReviewerTeam.Name)
|
||||
assert.Equal(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.Equal(t, 0, reviews[0].CodeCommentsCount)
|
||||
assert.False(t, reviews[1].Stale)
|
||||
assert.True(t, reviews[1].Official)
|
||||
assert.EqualValues(t, 1, reviews[1].Reviewer.ID)
|
||||
|
@@ -61,8 +61,8 @@ func TestAPIViewPulls(t *testing.T) {
|
||||
assert.Equal(t, "File-WoW", patch.Files[0].Name)
|
||||
// FIXME: The old name should be empty if it's a file add type
|
||||
assert.Equal(t, "File-WoW", patch.Files[0].OldName)
|
||||
assert.EqualValues(t, 1, patch.Files[0].Addition)
|
||||
assert.EqualValues(t, 0, patch.Files[0].Deletion)
|
||||
assert.Equal(t, 1, patch.Files[0].Addition)
|
||||
assert.Equal(t, 0, patch.Files[0].Deletion)
|
||||
assert.Equal(t, gitdiff.DiffFileAdd, patch.Files[0].Type)
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ func TestAPIViewPulls(t *testing.T) {
|
||||
if assert.Len(t, files, 1) {
|
||||
assert.Equal(t, "File-WoW", files[0].Filename)
|
||||
assert.Empty(t, files[0].PreviousFilename)
|
||||
assert.EqualValues(t, 1, files[0].Additions)
|
||||
assert.EqualValues(t, 1, files[0].Changes)
|
||||
assert.EqualValues(t, 0, files[0].Deletions)
|
||||
assert.Equal(t, 1, files[0].Additions)
|
||||
assert.Equal(t, 1, files[0].Changes)
|
||||
assert.Equal(t, 0, files[0].Deletions)
|
||||
assert.Equal(t, "added", files[0].Status)
|
||||
}
|
||||
}))
|
||||
@@ -97,8 +97,8 @@ func TestAPIViewPulls(t *testing.T) {
|
||||
if assert.Len(t, patch.Files, 1) {
|
||||
assert.Equal(t, "README.md", patch.Files[0].Name)
|
||||
assert.Equal(t, "README.md", patch.Files[0].OldName)
|
||||
assert.EqualValues(t, 4, patch.Files[0].Addition)
|
||||
assert.EqualValues(t, 1, patch.Files[0].Deletion)
|
||||
assert.Equal(t, 4, patch.Files[0].Addition)
|
||||
assert.Equal(t, 1, patch.Files[0].Deletion)
|
||||
assert.Equal(t, gitdiff.DiffFileChange, patch.Files[0].Type)
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ func TestAPIViewPulls(t *testing.T) {
|
||||
if assert.Len(t, files, 1) {
|
||||
assert.Equal(t, "README.md", files[0].Filename)
|
||||
// FIXME: The PreviousFilename name should be the same as Filename if it's a file change
|
||||
assert.Equal(t, "", files[0].PreviousFilename)
|
||||
assert.EqualValues(t, 4, files[0].Additions)
|
||||
assert.EqualValues(t, 1, files[0].Deletions)
|
||||
assert.Empty(t, files[0].PreviousFilename)
|
||||
assert.Equal(t, 4, files[0].Additions)
|
||||
assert.Equal(t, 1, files[0].Deletions)
|
||||
assert.Equal(t, "changed", files[0].Status)
|
||||
}
|
||||
}))
|
||||
@@ -307,12 +307,12 @@ func TestAPICreatePullWithFieldsSuccess(t *testing.T) {
|
||||
DecodeJSON(t, res, pull)
|
||||
|
||||
assert.NotNil(t, pull.Milestone)
|
||||
assert.EqualValues(t, opts.Milestone, pull.Milestone.ID)
|
||||
assert.Equal(t, opts.Milestone, pull.Milestone.ID)
|
||||
if assert.Len(t, pull.Assignees, 1) {
|
||||
assert.EqualValues(t, opts.Assignees[0], owner10.Name)
|
||||
assert.Equal(t, opts.Assignees[0], owner10.Name)
|
||||
}
|
||||
assert.NotNil(t, pull.Labels)
|
||||
assert.EqualValues(t, opts.Labels[0], pull.Labels[0].ID)
|
||||
assert.Equal(t, opts.Labels[0], pull.Labels[0].ID)
|
||||
}
|
||||
|
||||
func TestAPICreatePullWithFieldsFailure(t *testing.T) {
|
||||
@@ -366,7 +366,7 @@ func TestAPIEditPull(t *testing.T) {
|
||||
apiPull := new(api.PullRequest)
|
||||
resp := MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, apiPull)
|
||||
assert.EqualValues(t, "master", apiPull.Base.Name)
|
||||
assert.Equal(t, "master", apiPull.Base.Name)
|
||||
|
||||
newTitle := "edit a this pr"
|
||||
newBody := "edited body"
|
||||
@@ -377,7 +377,7 @@ func TestAPIEditPull(t *testing.T) {
|
||||
}).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, apiPull)
|
||||
assert.EqualValues(t, "feature/1", apiPull.Base.Name)
|
||||
assert.Equal(t, "feature/1", apiPull.Base.Name)
|
||||
// check comment history
|
||||
pull := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: apiPull.ID})
|
||||
err := pull.LoadIssue(db.DefaultContext)
|
||||
|
@@ -97,7 +97,7 @@ func createNewReleaseUsingAPI(t *testing.T, token string, owner *user_model.User
|
||||
Title: newRelease.Title,
|
||||
}
|
||||
unittest.AssertExistsAndLoadBean(t, rel)
|
||||
assert.EqualValues(t, newRelease.Note, rel.Note)
|
||||
assert.Equal(t, newRelease.Note, rel.Note)
|
||||
|
||||
return &newRelease
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) {
|
||||
Title: newRelease.Title,
|
||||
}
|
||||
unittest.AssertExistsAndLoadBean(t, rel)
|
||||
assert.EqualValues(t, rel.Note, newRelease.Note)
|
||||
assert.Equal(t, rel.Note, newRelease.Note)
|
||||
}
|
||||
|
||||
func TestAPICreateProtectedTagRelease(t *testing.T) {
|
||||
@@ -329,7 +329,7 @@ func TestAPIUploadAssetRelease(t *testing.T) {
|
||||
var attachment *api.Attachment
|
||||
DecodeJSON(t, resp, &attachment)
|
||||
|
||||
assert.EqualValues(t, filename, attachment.Name)
|
||||
assert.Equal(t, filename, attachment.Name)
|
||||
assert.EqualValues(t, 104, attachment.Size)
|
||||
|
||||
req = NewRequestWithBody(t, http.MethodPost, assetURL+"?name=test-asset", bytes.NewReader(body.Bytes())).
|
||||
@@ -340,7 +340,7 @@ func TestAPIUploadAssetRelease(t *testing.T) {
|
||||
var attachment2 *api.Attachment
|
||||
DecodeJSON(t, resp, &attachment2)
|
||||
|
||||
assert.EqualValues(t, "test-asset", attachment2.Name)
|
||||
assert.Equal(t, "test-asset", attachment2.Name)
|
||||
assert.EqualValues(t, 104, attachment2.Size)
|
||||
})
|
||||
|
||||
@@ -358,7 +358,7 @@ func TestAPIUploadAssetRelease(t *testing.T) {
|
||||
var attachment *api.Attachment
|
||||
DecodeJSON(t, resp, &attachment)
|
||||
|
||||
assert.EqualValues(t, "stream.bin", attachment.Name)
|
||||
assert.Equal(t, "stream.bin", attachment.Name)
|
||||
assert.EqualValues(t, 104, attachment.Size)
|
||||
})
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ func TestAPIDownloadArchive(t *testing.T) {
|
||||
bs2, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
// The locked URL should give the same bytes as the non-locked one
|
||||
assert.EqualValues(t, bs, bs2)
|
||||
assert.Equal(t, bs, bs2)
|
||||
|
||||
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.bundle", user2.Name, repo.Name))
|
||||
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
|
||||
@@ -88,7 +88,7 @@ func TestAPIDownloadArchive2(t *testing.T) {
|
||||
bs2, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
// The locked URL should give the same bytes as the non-locked one
|
||||
assert.EqualValues(t, bs, bs2)
|
||||
assert.Equal(t, bs, bs2)
|
||||
|
||||
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/bundle/master", user2.Name, repo.Name))
|
||||
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
|
||||
|
@@ -42,8 +42,8 @@ func TestAPIRepoBranchesPlain(t *testing.T) {
|
||||
var branches []*api.Branch
|
||||
assert.NoError(t, json.Unmarshal(bs, &branches))
|
||||
assert.Len(t, branches, 2)
|
||||
assert.EqualValues(t, "test_branch", branches[0].Name)
|
||||
assert.EqualValues(t, "master", branches[1].Name)
|
||||
assert.Equal(t, "test_branch", branches[0].Name)
|
||||
assert.Equal(t, "master", branches[1].Name)
|
||||
|
||||
link2, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch", repo3.Name))
|
||||
MakeRequest(t, NewRequest(t, "GET", link2.String()).AddTokenAuth(publicOnlyToken), http.StatusForbidden)
|
||||
@@ -53,7 +53,7 @@ func TestAPIRepoBranchesPlain(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
var branch api.Branch
|
||||
assert.NoError(t, json.Unmarshal(bs, &branch))
|
||||
assert.EqualValues(t, "test_branch", branch.Name)
|
||||
assert.Equal(t, "test_branch", branch.Name)
|
||||
|
||||
MakeRequest(t, NewRequest(t, "POST", link.String()).AddTokenAuth(publicOnlyToken), http.StatusForbidden)
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestAPIRepoBranchesPlain(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
var branch2 api.Branch
|
||||
assert.NoError(t, json.Unmarshal(bs, &branch2))
|
||||
assert.EqualValues(t, "test_branch2", branch2.Name)
|
||||
assert.EqualValues(t, branch.Commit.ID, branch2.Commit.ID)
|
||||
assert.Equal(t, "test_branch2", branch2.Name)
|
||||
assert.Equal(t, branch.Commit.ID, branch2.Commit.ID)
|
||||
|
||||
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
|
||||
bs, err = io.ReadAll(resp.Body)
|
||||
@@ -75,9 +75,9 @@ func TestAPIRepoBranchesPlain(t *testing.T) {
|
||||
branches = []*api.Branch{}
|
||||
assert.NoError(t, json.Unmarshal(bs, &branches))
|
||||
assert.Len(t, branches, 3)
|
||||
assert.EqualValues(t, "test_branch", branches[0].Name)
|
||||
assert.EqualValues(t, "test_branch2", branches[1].Name)
|
||||
assert.EqualValues(t, "master", branches[2].Name)
|
||||
assert.Equal(t, "test_branch", branches[0].Name)
|
||||
assert.Equal(t, "test_branch2", branches[1].Name)
|
||||
assert.Equal(t, "master", branches[2].Name)
|
||||
|
||||
link3, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch2", repo3.Name))
|
||||
MakeRequest(t, NewRequest(t, "DELETE", link3.String()), http.StatusNotFound)
|
||||
@@ -104,8 +104,8 @@ func TestAPIRepoBranchesMirror(t *testing.T) {
|
||||
var branches []*api.Branch
|
||||
assert.NoError(t, json.Unmarshal(bs, &branches))
|
||||
assert.Len(t, branches, 2)
|
||||
assert.EqualValues(t, "test_branch", branches[0].Name)
|
||||
assert.EqualValues(t, "master", branches[1].Name)
|
||||
assert.Equal(t, "test_branch", branches[0].Name)
|
||||
assert.Equal(t, "master", branches[1].Name)
|
||||
|
||||
link2, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch", repo5.Name))
|
||||
resp = MakeRequest(t, NewRequest(t, "GET", link2.String()).AddTokenAuth(token), http.StatusOK)
|
||||
@@ -113,7 +113,7 @@ func TestAPIRepoBranchesMirror(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
var branch api.Branch
|
||||
assert.NoError(t, json.Unmarshal(bs, &branch))
|
||||
assert.EqualValues(t, "test_branch", branch.Name)
|
||||
assert.Equal(t, "test_branch", branch.Name)
|
||||
|
||||
req := NewRequest(t, "POST", link.String()).AddTokenAuth(token)
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
@@ -121,10 +121,10 @@ func TestAPIRepoBranchesMirror(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusForbidden)
|
||||
bs, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
|
||||
assert.Equal(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
|
||||
|
||||
resp = MakeRequest(t, NewRequest(t, "DELETE", link2.String()).AddTokenAuth(token), http.StatusForbidden)
|
||||
bs, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
|
||||
assert.Equal(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
|
||||
}
|
||||
|
@@ -172,15 +172,15 @@ func TestAPICreateFile(t *testing.T) {
|
||||
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String())
|
||||
var fileResponse api.FileResponse
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
|
||||
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
|
||||
gitRepo.Close()
|
||||
}
|
||||
|
||||
@@ -198,10 +198,10 @@ func TestAPICreateFile(t *testing.T) {
|
||||
expectedSHA := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
|
||||
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/new/file%d.txt", fileID)
|
||||
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/new/file%d.txt", fileID)
|
||||
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
assert.EqualValues(t, createFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
assert.Equal(t, createFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
|
||||
// Test creating a file without a message
|
||||
createFileOptions = getCreateFileOptions()
|
||||
@@ -213,7 +213,7 @@ func TestAPICreateFile(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
expectedMessage := "Add " + treePath + "\n"
|
||||
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
|
||||
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
|
||||
|
||||
// Test trying to create a file that already exists, should fail
|
||||
createFileOptions = getCreateFileOptions()
|
||||
@@ -289,15 +289,15 @@ func TestAPICreateFile(t *testing.T) {
|
||||
latestCommit, _ := gitRepo.GetCommitByPath(treePath)
|
||||
expectedFileResponse := getExpectedFileResponseForCreate("user2/empty-repo", commitID, treePath, latestCommit.ID.String())
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
|
||||
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
|
||||
gitRepo.Close()
|
||||
})
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ func TestAPIDeleteFile(t *testing.T) {
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
assert.NotNil(t, fileResponse)
|
||||
assert.Nil(t, fileResponse.Content)
|
||||
assert.EqualValues(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
assert.Equal(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
|
||||
// Test deleting file without a message
|
||||
fileID++
|
||||
@@ -100,7 +100,7 @@ func TestAPIDeleteFile(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
expectedMessage := "Delete " + treePath + "\n"
|
||||
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
|
||||
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
|
||||
|
||||
// Test deleting a file with the wrong SHA
|
||||
fileID++
|
||||
|
@@ -140,11 +140,11 @@ func TestAPIUpdateFile(t *testing.T) {
|
||||
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
|
||||
var fileResponse api.FileResponse
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
|
||||
gitRepo.Close()
|
||||
}
|
||||
|
||||
@@ -163,10 +163,10 @@ func TestAPIUpdateFile(t *testing.T) {
|
||||
expectedSHA := "08bd14b2e2852529157324de9c226b3364e76136"
|
||||
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID)
|
||||
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID)
|
||||
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
assert.Equal(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message)
|
||||
|
||||
// Test updating a file and renaming it
|
||||
updateFileOptions = getUpdateFileOptions()
|
||||
@@ -183,9 +183,9 @@ func TestAPIUpdateFile(t *testing.T) {
|
||||
expectedSHA = "08bd14b2e2852529157324de9c226b3364e76136"
|
||||
expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID)
|
||||
expectedDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID)
|
||||
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
|
||||
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
|
||||
|
||||
// Test updating a file without a message
|
||||
updateFileOptions = getUpdateFileOptions()
|
||||
@@ -199,7 +199,7 @@ func TestAPIUpdateFile(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
expectedMessage := "Update " + treePath + "\n"
|
||||
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
|
||||
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
|
||||
|
||||
// Test updating a file with the wrong SHA
|
||||
fileID++
|
||||
|
@@ -105,18 +105,18 @@ func TestAPIChangeFiles(t *testing.T) {
|
||||
DecodeJSON(t, resp, &filesResponse)
|
||||
|
||||
// check create file
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
|
||||
assert.Equal(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
|
||||
|
||||
// check update file
|
||||
assert.EqualValues(t, expectedUpdateFileResponse.Content, filesResponse.Files[1])
|
||||
assert.Equal(t, expectedUpdateFileResponse.Content, filesResponse.Files[1])
|
||||
|
||||
// test commit info
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.Committer.Email, filesResponse.Commit.Committer.Email)
|
||||
assert.EqualValues(t, expectedCreateFileResponse.Commit.Committer.Name, filesResponse.Commit.Committer.Name)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.Committer.Email, filesResponse.Commit.Committer.Email)
|
||||
assert.Equal(t, expectedCreateFileResponse.Commit.Committer.Name, filesResponse.Commit.Committer.Name)
|
||||
|
||||
// test delete file
|
||||
assert.Nil(t, filesResponse.Files[2])
|
||||
@@ -149,15 +149,15 @@ func TestAPIChangeFiles(t *testing.T) {
|
||||
expectedUpdateSHA := "08bd14b2e2852529157324de9c226b3364e76136"
|
||||
expectedUpdateHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID)
|
||||
expectedUpdateDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID)
|
||||
assert.EqualValues(t, expectedCreateSHA, filesResponse.Files[0].SHA)
|
||||
assert.EqualValues(t, expectedCreateHTMLURL, *filesResponse.Files[0].HTMLURL)
|
||||
assert.EqualValues(t, expectedCreateDownloadURL, *filesResponse.Files[0].DownloadURL)
|
||||
assert.EqualValues(t, expectedUpdateSHA, filesResponse.Files[1].SHA)
|
||||
assert.EqualValues(t, expectedUpdateHTMLURL, *filesResponse.Files[1].HTMLURL)
|
||||
assert.EqualValues(t, expectedUpdateDownloadURL, *filesResponse.Files[1].DownloadURL)
|
||||
assert.Equal(t, expectedCreateSHA, filesResponse.Files[0].SHA)
|
||||
assert.Equal(t, expectedCreateHTMLURL, *filesResponse.Files[0].HTMLURL)
|
||||
assert.Equal(t, expectedCreateDownloadURL, *filesResponse.Files[0].DownloadURL)
|
||||
assert.Equal(t, expectedUpdateSHA, filesResponse.Files[1].SHA)
|
||||
assert.Equal(t, expectedUpdateHTMLURL, *filesResponse.Files[1].HTMLURL)
|
||||
assert.Equal(t, expectedUpdateDownloadURL, *filesResponse.Files[1].DownloadURL)
|
||||
assert.Nil(t, filesResponse.Files[2])
|
||||
|
||||
assert.EqualValues(t, changeFilesOptions.Message+"\n", filesResponse.Commit.Message)
|
||||
assert.Equal(t, changeFilesOptions.Message+"\n", filesResponse.Commit.Message)
|
||||
|
||||
// Test updating a file and renaming it
|
||||
changeFilesOptions = getChangeFilesOptions()
|
||||
@@ -175,9 +175,9 @@ func TestAPIChangeFiles(t *testing.T) {
|
||||
expectedUpdateSHA = "08bd14b2e2852529157324de9c226b3364e76136"
|
||||
expectedUpdateHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID)
|
||||
expectedUpdateDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID)
|
||||
assert.EqualValues(t, expectedUpdateSHA, filesResponse.Files[0].SHA)
|
||||
assert.EqualValues(t, expectedUpdateHTMLURL, *filesResponse.Files[0].HTMLURL)
|
||||
assert.EqualValues(t, expectedUpdateDownloadURL, *filesResponse.Files[0].DownloadURL)
|
||||
assert.Equal(t, expectedUpdateSHA, filesResponse.Files[0].SHA)
|
||||
assert.Equal(t, expectedUpdateHTMLURL, *filesResponse.Files[0].HTMLURL)
|
||||
assert.Equal(t, expectedUpdateDownloadURL, *filesResponse.Files[0].DownloadURL)
|
||||
|
||||
// Test updating a file without a message
|
||||
changeFilesOptions = getChangeFilesOptions()
|
||||
@@ -197,7 +197,7 @@ func TestAPIChangeFiles(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, &filesResponse)
|
||||
expectedMessage := fmt.Sprintf("Add %v\nUpdate %v\nDelete %v\n", createTreePath, updateTreePath, deleteTreePath)
|
||||
assert.EqualValues(t, expectedMessage, filesResponse.Commit.Message)
|
||||
assert.Equal(t, expectedMessage, filesResponse.Commit.Message)
|
||||
|
||||
// Test updating a file with the wrong SHA
|
||||
fileID++
|
||||
|
@@ -99,7 +99,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
||||
lastCommit, err := gitRepo.GetCommitByPath("README.md")
|
||||
assert.NoError(t, err)
|
||||
expectedContentsListResponse := getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
|
||||
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
|
||||
|
||||
// No ref
|
||||
refType = "branch"
|
||||
@@ -109,7 +109,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
||||
assert.NotNil(t, contentsListResponse)
|
||||
|
||||
expectedContentsListResponse = getExpectedContentsListResponseForContents(repo1.DefaultBranch, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
|
||||
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
|
||||
|
||||
// ref is the branch we created above in setup
|
||||
ref = newBranch
|
||||
@@ -123,7 +123,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
||||
lastCommit, err = branchCommit.GetCommitByPath("README.md")
|
||||
assert.NoError(t, err)
|
||||
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
|
||||
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
|
||||
|
||||
// ref is the new tag we created above in setup
|
||||
ref = newTag
|
||||
@@ -137,7 +137,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
||||
lastCommit, err = tagCommit.GetCommitByPath("README.md")
|
||||
assert.NoError(t, err)
|
||||
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
|
||||
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
|
||||
|
||||
// ref is a commit
|
||||
ref = commitID
|
||||
@@ -147,7 +147,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
||||
DecodeJSON(t, resp, &contentsListResponse)
|
||||
assert.NotNil(t, contentsListResponse)
|
||||
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, commitID)
|
||||
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
|
||||
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
|
||||
|
||||
// Test file contents a file with a bad ref
|
||||
ref = "badref"
|
||||
|
@@ -102,7 +102,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
||||
assert.NotNil(t, contentsResponse)
|
||||
lastCommit, _ := gitRepo.GetCommitByPath("README.md")
|
||||
expectedContentsResponse := getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
|
||||
assert.Equal(t, *expectedContentsResponse, contentsResponse)
|
||||
|
||||
// No ref
|
||||
refType = "branch"
|
||||
@@ -111,7 +111,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
||||
DecodeJSON(t, resp, &contentsResponse)
|
||||
assert.NotNil(t, contentsResponse)
|
||||
expectedContentsResponse = getExpectedContentsResponseForContents(repo1.DefaultBranch, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
|
||||
assert.Equal(t, *expectedContentsResponse, contentsResponse)
|
||||
|
||||
// ref is the branch we created above in setup
|
||||
ref = newBranch
|
||||
@@ -123,7 +123,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
||||
branchCommit, _ := gitRepo.GetBranchCommit(ref)
|
||||
lastCommit, _ = branchCommit.GetCommitByPath("README.md")
|
||||
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
|
||||
assert.Equal(t, *expectedContentsResponse, contentsResponse)
|
||||
|
||||
// ref is the new tag we created above in setup
|
||||
ref = newTag
|
||||
@@ -135,7 +135,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
||||
tagCommit, _ := gitRepo.GetTagCommit(ref)
|
||||
lastCommit, _ = tagCommit.GetCommitByPath("README.md")
|
||||
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
|
||||
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
|
||||
assert.Equal(t, *expectedContentsResponse, contentsResponse)
|
||||
|
||||
// ref is a commit
|
||||
ref = commitID
|
||||
@@ -145,7 +145,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
||||
DecodeJSON(t, resp, &contentsResponse)
|
||||
assert.NotNil(t, contentsResponse)
|
||||
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, commitID)
|
||||
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
|
||||
assert.Equal(t, *expectedContentsResponse, contentsResponse)
|
||||
|
||||
// Test file contents a file with a bad ref
|
||||
ref = "badref"
|
||||
@@ -178,22 +178,22 @@ func TestAPIGetContentsRefFormats(t *testing.T) {
|
||||
resp := MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/"+file), http.StatusOK)
|
||||
raw, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, content, string(raw))
|
||||
assert.Equal(t, content, string(raw))
|
||||
|
||||
resp = MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/"+sha+"/"+file), http.StatusOK)
|
||||
raw, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, content, string(raw))
|
||||
assert.Equal(t, content, string(raw))
|
||||
|
||||
resp = MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/"+file+"?ref="+sha), http.StatusOK)
|
||||
raw, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, content, string(raw))
|
||||
assert.Equal(t, content, string(raw))
|
||||
|
||||
resp = MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/"+file+"?ref=master"), http.StatusOK)
|
||||
raw, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, content, string(raw))
|
||||
assert.Equal(t, content, string(raw))
|
||||
|
||||
_ = MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/docs/README.md?ref=main"), http.StatusNotFound)
|
||||
_ = MakeRequest(t, NewRequest(t, http.MethodGet, "/api/v1/repos/user2/repo1/raw/README.md?ref=main"), http.StatusOK)
|
||||
|
@@ -72,12 +72,12 @@ func TestAPIReposGitCommitList(t *testing.T) {
|
||||
DecodeJSON(t, resp, &apiData)
|
||||
|
||||
assert.Len(t, apiData, 2)
|
||||
assert.EqualValues(t, "cfe3b3c1fd36fba04f9183287b106497e1afe986", apiData[0].CommitMeta.SHA)
|
||||
assert.Equal(t, "cfe3b3c1fd36fba04f9183287b106497e1afe986", apiData[0].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"link_hi", "test.csv"}, apiData[0].Files)
|
||||
assert.EqualValues(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[1].CommitMeta.SHA)
|
||||
assert.Equal(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[1].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"test.csv"}, apiData[1].Files)
|
||||
|
||||
assert.EqualValues(t, "2", resp.Header().Get("X-Total"))
|
||||
assert.Equal(t, "2", resp.Header().Get("X-Total"))
|
||||
}
|
||||
|
||||
func TestAPIReposGitCommitListNotMaster(t *testing.T) {
|
||||
@@ -96,14 +96,14 @@ func TestAPIReposGitCommitListNotMaster(t *testing.T) {
|
||||
DecodeJSON(t, resp, &apiData)
|
||||
|
||||
assert.Len(t, apiData, 3)
|
||||
assert.EqualValues(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", apiData[0].CommitMeta.SHA)
|
||||
assert.Equal(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", apiData[0].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"readme.md"}, apiData[0].Files)
|
||||
assert.EqualValues(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", apiData[1].CommitMeta.SHA)
|
||||
assert.Equal(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", apiData[1].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"readme.md"}, apiData[1].Files)
|
||||
assert.EqualValues(t, "5099b81332712fe655e34e8dd63574f503f61811", apiData[2].CommitMeta.SHA)
|
||||
assert.Equal(t, "5099b81332712fe655e34e8dd63574f503f61811", apiData[2].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"readme.md"}, apiData[2].Files)
|
||||
|
||||
assert.EqualValues(t, "3", resp.Header().Get("X-Total"))
|
||||
assert.Equal(t, "3", resp.Header().Get("X-Total"))
|
||||
}
|
||||
|
||||
func TestAPIReposGitCommitListPage2Empty(t *testing.T) {
|
||||
@@ -177,7 +177,7 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) {
|
||||
reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff", user.Name).
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, reqDiff, http.StatusOK)
|
||||
assert.EqualValues(t,
|
||||
assert.Equal(t,
|
||||
"commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 <user2@example.com>\nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n",
|
||||
resp.Body.String())
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) {
|
||||
reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch", user.Name).
|
||||
AddTokenAuth(token)
|
||||
resp = MakeRequest(t, reqPatch, http.StatusOK)
|
||||
assert.EqualValues(t,
|
||||
assert.Equal(t,
|
||||
"From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 <user2@example.com>\nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n",
|
||||
resp.Body.String())
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func TestGetFileHistory(t *testing.T) {
|
||||
assert.Equal(t, "f27c2b2b03dcab38beaf89b0ab4ff61f6de63441", apiData[0].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"readme.md"}, apiData[0].Files)
|
||||
|
||||
assert.EqualValues(t, "1", resp.Header().Get("X-Total"))
|
||||
assert.Equal(t, "1", resp.Header().Get("X-Total"))
|
||||
}
|
||||
|
||||
func TestGetFileHistoryNotOnMaster(t *testing.T) {
|
||||
@@ -229,5 +229,5 @@ func TestGetFileHistoryNotOnMaster(t *testing.T) {
|
||||
assert.Equal(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[0].CommitMeta.SHA)
|
||||
compareCommitFiles(t, []string{"test.csv"}, apiData[0].Files)
|
||||
|
||||
assert.EqualValues(t, "1", resp.Header().Get("X-Total"))
|
||||
assert.Equal(t, "1", resp.Header().Get("X-Total"))
|
||||
}
|
||||
|
@@ -112,7 +112,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
|
||||
var lfsLock api.LFSLockResponse
|
||||
DecodeJSON(t, resp, &lfsLock)
|
||||
assert.Equal(t, test.user.Name, lfsLock.Lock.Owner.Name)
|
||||
assert.EqualValues(t, lfsLock.Lock.LockedAt.Format(time.RFC3339), lfsLock.Lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
|
||||
assert.Equal(t, lfsLock.Lock.LockedAt.Format(time.RFC3339), lfsLock.Lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
|
||||
for _, id := range test.addTime {
|
||||
resultsTests[id].locksTimes = append(resultsTests[id].locksTimes, time.Now())
|
||||
}
|
||||
@@ -129,9 +129,9 @@ func TestAPILFSLocksLogged(t *testing.T) {
|
||||
DecodeJSON(t, resp, &lfsLocks)
|
||||
assert.Len(t, lfsLocks.Locks, test.totalCount)
|
||||
for i, lock := range lfsLocks.Locks {
|
||||
assert.EqualValues(t, test.locksOwners[i].Name, lock.Owner.Name)
|
||||
assert.Equal(t, test.locksOwners[i].Name, lock.Owner.Name)
|
||||
assert.WithinDuration(t, test.locksTimes[i], lock.LockedAt, 10*time.Second)
|
||||
assert.EqualValues(t, lock.LockedAt.Format(time.RFC3339), lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
|
||||
assert.Equal(t, lock.LockedAt.Format(time.RFC3339), lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
|
||||
}
|
||||
|
||||
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/verify", test.repo.FullName()), map[string]string{})
|
||||
@@ -143,7 +143,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
|
||||
assert.Len(t, lfsLocksVerify.Ours, test.oursCount)
|
||||
assert.Len(t, lfsLocksVerify.Theirs, test.theirsCount)
|
||||
for _, lock := range lfsLocksVerify.Ours {
|
||||
assert.EqualValues(t, test.user.Name, lock.Owner.Name)
|
||||
assert.Equal(t, test.user.Name, lock.Owner.Name)
|
||||
deleteTests = append(deleteTests, struct {
|
||||
user *user_model.User
|
||||
repo *repo_model.Repository
|
||||
|
@@ -40,7 +40,7 @@ func TestAPIRepoLFSMigrateLocal(t *testing.T) {
|
||||
LFS: true,
|
||||
}).AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, NoExpectedStatus)
|
||||
assert.EqualValues(t, http.StatusCreated, resp.Code)
|
||||
assert.Equal(t, http.StatusCreated, resp.Code)
|
||||
|
||||
store := lfs.NewContentStore()
|
||||
ok, _ := store.Verify(lfs.Pointer{Oid: "fb8f7d8435968c4f82a726a92395be4d16f2f63116caf36c8ad35c60831ab041", Size: 6})
|
||||
|
@@ -30,11 +30,11 @@ func TestAPIReposRaw(t *testing.T) {
|
||||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md", user.Name, ref).
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type"))
|
||||
assert.Equal(t, "file", resp.Header().Get("x-gitea-object-type"))
|
||||
}
|
||||
// Test default branch
|
||||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md", user.Name).
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type"))
|
||||
assert.Equal(t, "file", resp.Header().Get("x-gitea-object-type"))
|
||||
}
|
||||
|
@@ -48,10 +48,10 @@ func TestAPIRepoTags(t *testing.T) {
|
||||
assert.Len(t, tags, 2)
|
||||
for _, tag := range tags {
|
||||
if tag.Name != "v1.1" {
|
||||
assert.EqualValues(t, newTag.Name, tag.Name)
|
||||
assert.EqualValues(t, newTag.Message, tag.Message)
|
||||
assert.EqualValues(t, "nice!\nand some text", tag.Message)
|
||||
assert.EqualValues(t, newTag.Commit.SHA, tag.Commit.SHA)
|
||||
assert.Equal(t, newTag.Name, tag.Name)
|
||||
assert.Equal(t, newTag.Message, tag.Message)
|
||||
assert.Equal(t, "nice!\nand some text", tag.Message)
|
||||
assert.Equal(t, newTag.Commit.SHA, tag.Commit.SHA)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestAPIRepoTags(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
var tag *api.Tag
|
||||
DecodeJSON(t, resp, &tag)
|
||||
assert.EqualValues(t, newTag, tag)
|
||||
assert.Equal(t, newTag, tag)
|
||||
|
||||
// delete tag
|
||||
delReq := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/tags/%s", user.Name, repoName, newTag.Name).
|
||||
|
@@ -37,15 +37,15 @@ func TestAPIRepoTeams(t *testing.T) {
|
||||
var teams []*api.Team
|
||||
DecodeJSON(t, res, &teams)
|
||||
if assert.Len(t, teams, 2) {
|
||||
assert.EqualValues(t, "Owners", teams[0].Name)
|
||||
assert.Equal(t, "Owners", teams[0].Name)
|
||||
assert.True(t, teams[0].CanCreateOrgRepo)
|
||||
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units), "%v == %v", unit.AllUnitKeyNames(), teams[0].Units)
|
||||
assert.EqualValues(t, "owner", teams[0].Permission)
|
||||
assert.Equal(t, "owner", teams[0].Permission)
|
||||
|
||||
assert.EqualValues(t, "test_team", teams[1].Name)
|
||||
assert.Equal(t, "test_team", teams[1].Name)
|
||||
assert.False(t, teams[1].CanCreateOrgRepo)
|
||||
assert.EqualValues(t, []string{"repo.issues"}, teams[1].Units)
|
||||
assert.EqualValues(t, "write", teams[1].Permission)
|
||||
assert.Equal(t, []string{"repo.issues"}, teams[1].Units)
|
||||
assert.Equal(t, "write", teams[1].Permission)
|
||||
}
|
||||
|
||||
// IsTeam
|
||||
@@ -54,7 +54,7 @@ func TestAPIRepoTeams(t *testing.T) {
|
||||
res = MakeRequest(t, req, http.StatusOK)
|
||||
var team *api.Team
|
||||
DecodeJSON(t, res, &team)
|
||||
assert.EqualValues(t, teams[1], team)
|
||||
assert.Equal(t, teams[1], team)
|
||||
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/teams/%s", publicOrgRepo.FullName(), "NonExistingTeam")).
|
||||
AddTokenAuth(token)
|
||||
|
@@ -37,7 +37,7 @@ func TestAPIUserReposNotLogin(t *testing.T) {
|
||||
unittest.Cond("is_private = ?", false))
|
||||
assert.Len(t, apiRepos, expectedLen)
|
||||
for _, repo := range apiRepos {
|
||||
assert.EqualValues(t, user.ID, repo.Owner.ID)
|
||||
assert.Equal(t, user.ID, repo.Owner.ID)
|
||||
assert.False(t, repo.Private)
|
||||
}
|
||||
}
|
||||
@@ -266,25 +266,25 @@ func TestAPIViewRepo(t *testing.T) {
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &repo)
|
||||
assert.EqualValues(t, 1, repo.ID)
|
||||
assert.EqualValues(t, "repo1", repo.Name)
|
||||
assert.EqualValues(t, 2, repo.Releases)
|
||||
assert.EqualValues(t, 1, repo.OpenIssues)
|
||||
assert.EqualValues(t, 3, repo.OpenPulls)
|
||||
assert.Equal(t, "repo1", repo.Name)
|
||||
assert.Equal(t, 2, repo.Releases)
|
||||
assert.Equal(t, 1, repo.OpenIssues)
|
||||
assert.Equal(t, 3, repo.OpenPulls)
|
||||
|
||||
req = NewRequest(t, "GET", "/api/v1/repos/user12/repo10")
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &repo)
|
||||
assert.EqualValues(t, 10, repo.ID)
|
||||
assert.EqualValues(t, "repo10", repo.Name)
|
||||
assert.EqualValues(t, 1, repo.OpenPulls)
|
||||
assert.EqualValues(t, 1, repo.Forks)
|
||||
assert.Equal(t, "repo10", repo.Name)
|
||||
assert.Equal(t, 1, repo.OpenPulls)
|
||||
assert.Equal(t, 1, repo.Forks)
|
||||
|
||||
req = NewRequest(t, "GET", "/api/v1/repos/user5/repo4")
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &repo)
|
||||
assert.EqualValues(t, 4, repo.ID)
|
||||
assert.EqualValues(t, "repo4", repo.Name)
|
||||
assert.EqualValues(t, 1, repo.Stars)
|
||||
assert.Equal(t, "repo4", repo.Name)
|
||||
assert.Equal(t, 1, repo.Stars)
|
||||
}
|
||||
|
||||
func TestAPIOrgRepos(t *testing.T) {
|
||||
@@ -337,9 +337,9 @@ func TestAPIOrgReposWithCodeUnitDisabled(t *testing.T) {
|
||||
var units []unit_model.Type
|
||||
units = append(units, unit_model.TypeCode)
|
||||
|
||||
if err := repo_service.UpdateRepositoryUnits(db.DefaultContext, repo21, nil, units); err != nil {
|
||||
assert.Fail(t, "should have been able to delete code repository unit; failed to %v", err)
|
||||
}
|
||||
err := repo_service.UpdateRepositoryUnits(db.DefaultContext, repo21, nil, units)
|
||||
assert.NoError(t, err, "should have been able to delete code repository unit")
|
||||
|
||||
assert.False(t, repo21.UnitEnabled(db.DefaultContext, unit_model.TypeCode))
|
||||
|
||||
session := loginUser(t, "user2")
|
||||
@@ -403,12 +403,12 @@ func TestAPIRepoMigrate(t *testing.T) {
|
||||
case "Remote visit addressed rate limitation.":
|
||||
t.Log("test hit github rate limitation")
|
||||
case "You can not import from disallowed hosts.":
|
||||
assert.EqualValues(t, "private-ip", testCase.repoName)
|
||||
assert.Equal(t, "private-ip", testCase.repoName)
|
||||
default:
|
||||
assert.FailNow(t, "unexpected error '%v' on url '%s'", respJSON["message"], testCase.cloneURL)
|
||||
assert.FailNow(t, "unexpected error", "unexpected error '%v' on url '%s'", respJSON["message"], testCase.cloneURL)
|
||||
}
|
||||
} else {
|
||||
assert.EqualValues(t, testCase.expectedStatus, resp.Code)
|
||||
assert.Equal(t, testCase.expectedStatus, resp.Code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ func TestAPITopicSearch(t *testing.T) {
|
||||
res := MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 6)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// pagination search topics first page
|
||||
topics.TopicNames = nil
|
||||
@@ -40,7 +40,7 @@ func TestAPITopicSearch(t *testing.T) {
|
||||
res = MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 4)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// pagination search topics second page
|
||||
topics.TopicNames = nil
|
||||
@@ -50,7 +50,7 @@ func TestAPITopicSearch(t *testing.T) {
|
||||
res = MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 2)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// add keyword search
|
||||
query = url.Values{"page": []string{"1"}, "limit": []string{"4"}}
|
||||
@@ -66,8 +66,8 @@ func TestAPITopicSearch(t *testing.T) {
|
||||
DecodeJSON(t, res, &topics)
|
||||
if assert.Len(t, topics.TopicNames, 1) {
|
||||
assert.EqualValues(t, 2, topics.TopicNames[0].ID)
|
||||
assert.EqualValues(t, "database", topics.TopicNames[0].Name)
|
||||
assert.EqualValues(t, 1, topics.TopicNames[0].RepoCount)
|
||||
assert.Equal(t, "database", topics.TopicNames[0].Name)
|
||||
assert.Equal(t, 1, topics.TopicNames[0].RepoCount)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ func TestAPIExposedSettings(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
DecodeJSON(t, resp, &apiSettings)
|
||||
assert.EqualValues(t, &api.GeneralAPISettings{
|
||||
assert.Equal(t, &api.GeneralAPISettings{
|
||||
MaxResponseItems: setting.API.MaxResponseItems,
|
||||
DefaultPagingNum: setting.API.DefaultPagingNum,
|
||||
DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
|
||||
@@ -42,7 +42,7 @@ func TestAPIExposedSettings(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
DecodeJSON(t, resp, &repo)
|
||||
assert.EqualValues(t, &api.GeneralRepoSettings{
|
||||
assert.Equal(t, &api.GeneralRepoSettings{
|
||||
MirrorsDisabled: !setting.Mirror.Enabled,
|
||||
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
||||
MigrationsDisabled: setting.Repository.DisableMigrations,
|
||||
@@ -55,7 +55,7 @@ func TestAPIExposedSettings(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
DecodeJSON(t, resp, &attachment)
|
||||
assert.EqualValues(t, &api.GeneralAttachmentSettings{
|
||||
assert.Equal(t, &api.GeneralAttachmentSettings{
|
||||
Enabled: setting.Attachment.Enabled,
|
||||
AllowedTypes: setting.Attachment.AllowedTypes,
|
||||
MaxFiles: setting.Attachment.MaxFiles,
|
||||
|
@@ -40,9 +40,9 @@ func TestAPITeam(t *testing.T) {
|
||||
|
||||
var apiTeam api.Team
|
||||
DecodeJSON(t, resp, &apiTeam)
|
||||
assert.EqualValues(t, team.ID, apiTeam.ID)
|
||||
assert.Equal(t, team.ID, apiTeam.ID)
|
||||
assert.Equal(t, team.Name, apiTeam.Name)
|
||||
assert.EqualValues(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
|
||||
assert.Equal(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
|
||||
|
||||
// non team member user will not access the teams details
|
||||
teamUser2 := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 3})
|
||||
@@ -247,10 +247,10 @@ func checkTeamResponse(t *testing.T, testName string, apiTeam *api.Team, name, d
|
||||
if units != nil {
|
||||
sort.StringSlice(units).Sort()
|
||||
sort.StringSlice(apiTeam.Units).Sort()
|
||||
assert.EqualValues(t, units, apiTeam.Units, "units")
|
||||
assert.Equal(t, units, apiTeam.Units, "units")
|
||||
}
|
||||
if unitsMap != nil {
|
||||
assert.EqualValues(t, unitsMap, apiTeam.UnitsMap, "unitsMap")
|
||||
assert.Equal(t, unitsMap, apiTeam.UnitsMap, "unitsMap")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -40,8 +40,8 @@ func TestAPITeamUser(t *testing.T) {
|
||||
expectedUser := convert.ToUser(db.DefaultContext, user, user)
|
||||
|
||||
// test time via unix timestamp
|
||||
assert.EqualValues(t, expectedUser.LastLogin.Unix(), user2.LastLogin.Unix())
|
||||
assert.EqualValues(t, expectedUser.Created.Unix(), user2.Created.Unix())
|
||||
assert.Equal(t, expectedUser.LastLogin.Unix(), user2.LastLogin.Unix())
|
||||
assert.Equal(t, expectedUser.Created.Unix(), user2.Created.Unix())
|
||||
expectedUser.LastLogin = user2.LastLogin
|
||||
expectedUser.Created = user2.Created
|
||||
|
||||
|
@@ -507,7 +507,7 @@ func runTestCase(t *testing.T, testCase *requiredScopeTestCase, user *user_model
|
||||
} else if minRequiredLevel == auth_model.Write {
|
||||
unauthorizedLevel = auth_model.Read
|
||||
} else {
|
||||
assert.FailNow(t, "Invalid test case: Unknown access token scope level: %v", minRequiredLevel)
|
||||
assert.FailNow(t, "Invalid test case", "Unknown access token scope level: %v", minRequiredLevel)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -94,7 +94,7 @@ func TestBasicAuthWithWebAuthn(t *testing.T) {
|
||||
}
|
||||
var userParsed userResponse
|
||||
DecodeJSON(t, resp, &userParsed)
|
||||
assert.EqualValues(t, "Basic authorization is not allowed while webAuthn enrolled", userParsed.Message)
|
||||
assert.Equal(t, "Basic authorization is not allowed while webAuthn enrolled", userParsed.Message)
|
||||
|
||||
// user32 has webauthn enrolled, he can't request git protocol with basic auth
|
||||
req = NewRequest(t, "GET", "/user2/repo1/info/refs")
|
||||
|
@@ -28,7 +28,7 @@ func TestAPIListEmails(t *testing.T) {
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
|
||||
assert.EqualValues(t, []*api.Email{
|
||||
assert.Equal(t, []*api.Email{
|
||||
{
|
||||
Email: "user2@example.com",
|
||||
Verified: true,
|
||||
@@ -66,7 +66,7 @@ func TestAPIAddEmail(t *testing.T) {
|
||||
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
assert.EqualValues(t, []*api.Email{
|
||||
assert.Equal(t, []*api.Email{
|
||||
{
|
||||
Email: "user2@example.com",
|
||||
Verified: true,
|
||||
@@ -119,7 +119,7 @@ func TestAPIDeleteEmail(t *testing.T) {
|
||||
|
||||
var emails []*api.Email
|
||||
DecodeJSON(t, resp, &emails)
|
||||
assert.EqualValues(t, []*api.Email{
|
||||
assert.Equal(t, []*api.Email{
|
||||
{
|
||||
Email: "user2@example.com",
|
||||
Verified: true,
|
||||
|
@@ -66,7 +66,7 @@ func TestAPIUserSearchNotLoggedIn(t *testing.T) {
|
||||
for _, user := range results.Data {
|
||||
assert.Contains(t, user.UserName, query)
|
||||
modelUser = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: user.ID})
|
||||
assert.EqualValues(t, modelUser.GetPlaceholderEmail(), user.Email)
|
||||
assert.Equal(t, modelUser.GetPlaceholderEmail(), user.Email)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ func TestAPIUserSearchSystemUsers(t *testing.T) {
|
||||
assert.NotEmpty(t, results.Data)
|
||||
if assert.Len(t, results.Data, 1) {
|
||||
user := results.Data[0]
|
||||
assert.EqualValues(t, user.UserName, systemUser.Name)
|
||||
assert.EqualValues(t, user.ID, systemUser.ID)
|
||||
assert.Equal(t, user.UserName, systemUser.Name)
|
||||
assert.Equal(t, user.ID, systemUser.ID)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestAPIUserSearchAdminLoggedInUserHidden(t *testing.T) {
|
||||
for _, user := range results.Data {
|
||||
assert.Contains(t, user.UserName, query)
|
||||
assert.NotEmpty(t, user.Email)
|
||||
assert.EqualValues(t, "private", user.Visibility)
|
||||
assert.Equal(t, "private", user.Visibility)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ func TestDatabaseCollation(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.Database.CharsetCollation, "utf8mb4_bin")()
|
||||
r, err := db.CheckCollations(x)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "utf8mb4_bin", r.ExpectedCollation)
|
||||
assert.Equal(t, "utf8mb4_bin", r.ExpectedCollation)
|
||||
assert.NoError(t, db.ConvertDatabaseTable())
|
||||
r, err = db.CheckCollations(x)
|
||||
assert.NoError(t, err)
|
||||
|
@@ -178,7 +178,7 @@ func (c *compareDump) assertEquals(repoBefore, repoAfter *repo_model.Repository)
|
||||
}).([]*base.Comment)
|
||||
assert.True(c.t, ok)
|
||||
for _, comment := range comments {
|
||||
assert.EqualValues(c.t, issue.Number, comment.IssueIndex)
|
||||
assert.Equal(c.t, issue.Number, comment.IssueIndex)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func (c *compareDump) assertEquals(repoBefore, repoAfter *repo_model.Repository)
|
||||
comments, ok := c.assertEqual(filename, []base.Comment{}, compareFields{}).([]*base.Comment)
|
||||
assert.True(c.t, ok)
|
||||
for _, comment := range comments {
|
||||
assert.EqualValues(c.t, pr.Number, comment.IssueIndex)
|
||||
assert.Equal(c.t, pr.Number, comment.IssueIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (c *compareDump) assertEquals(repoBefore, repoAfter *repo_model.Repository)
|
||||
func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after any) {
|
||||
_, beforeErr := os.Stat(beforeFilename)
|
||||
_, afterErr := os.Stat(afterFilename)
|
||||
assert.EqualValues(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist))
|
||||
assert.Equal(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist))
|
||||
if errors.Is(beforeErr, os.ErrNotExist) {
|
||||
return
|
||||
}
|
||||
@@ -265,7 +265,7 @@ func (c *compareDump) assertEqual(filename string, kind any, fields compareField
|
||||
}
|
||||
|
||||
func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) any {
|
||||
assert.EqualValues(c.t, before.Len(), after.Len())
|
||||
assert.Equal(c.t, before.Len(), after.Len())
|
||||
if before.Len() == after.Len() {
|
||||
for i := 0; i < before.Len(); i++ {
|
||||
_ = c.assertEqualValues(
|
||||
@@ -298,15 +298,15 @@ func (c *compareDump) assertEqualValues(before, after reflect.Value, fields comp
|
||||
assert.True(c.t, ok)
|
||||
as, ok := ai.(string)
|
||||
assert.True(c.t, ok)
|
||||
assert.EqualValues(c.t, compare.transform(bs), compare.transform(as))
|
||||
assert.Equal(c.t, compare.transform(bs), compare.transform(as))
|
||||
continue
|
||||
}
|
||||
if compare.before != nil && compare.after != nil {
|
||||
//
|
||||
// The fields are expected to have different values
|
||||
//
|
||||
assert.EqualValues(c.t, compare.before, bi)
|
||||
assert.EqualValues(c.t, compare.after, ai)
|
||||
assert.Equal(c.t, compare.before, bi)
|
||||
assert.Equal(c.t, compare.after, ai)
|
||||
continue
|
||||
}
|
||||
if compare.nested != nil {
|
||||
@@ -317,7 +317,7 @@ func (c *compareDump) assertEqualValues(before, after reflect.Value, fields comp
|
||||
continue
|
||||
}
|
||||
}
|
||||
assert.EqualValues(c.t, bi, ai)
|
||||
assert.Equal(c.t, bi, ai)
|
||||
}
|
||||
return after.Interface()
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
// Check if master branch has been locked successfully
|
||||
flashMsg := session.GetCookieFlashMessage()
|
||||
assert.EqualValues(t, `Branch protection for rule "master" has been updated.`, flashMsg.SuccessMsg)
|
||||
assert.Equal(t, `Branch protection for rule "master" has been updated.`, flashMsg.SuccessMsg)
|
||||
|
||||
// Request editor page
|
||||
req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
|
||||
@@ -103,11 +103,11 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
|
||||
res := make(map[string]string)
|
||||
assert.NoError(t, json.NewDecoder(resp.Body).Decode(&res))
|
||||
assert.EqualValues(t, "/user2/repo1/settings/branches", res["redirect"])
|
||||
assert.Equal(t, "/user2/repo1/settings/branches", res["redirect"])
|
||||
|
||||
// Check if master branch has been locked successfully
|
||||
flashMsg = session.GetCookieFlashMessage()
|
||||
assert.EqualValues(t, `Removing branch protection rule "1" failed.`, flashMsg.ErrorMsg)
|
||||
assert.Equal(t, `Removing branch protection rule "1" failed.`, flashMsg.ErrorMsg)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
|
||||
// Verify the change
|
||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, newContent, resp.Body.String())
|
||||
assert.Equal(t, newContent, resp.Body.String())
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
|
||||
// Verify the change
|
||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, newContent, resp.Body.String())
|
||||
assert.Equal(t, newContent, resp.Body.String())
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -215,10 +215,10 @@ func TestWebGitCommitEmail(t *testing.T) {
|
||||
assert.Contains(t, errMsg, translation.NewLocale("en-US").Tr("repo.editor.invalid_commit_email"))
|
||||
} else {
|
||||
require.NotEqual(t, lastCommit.ID.String(), newCommit.ID.String())
|
||||
assert.EqualValues(t, expectedUserName, newCommit.Author.Name)
|
||||
assert.EqualValues(t, expectedEmail, newCommit.Author.Email)
|
||||
assert.EqualValues(t, expectedUserName, newCommit.Committer.Name)
|
||||
assert.EqualValues(t, expectedEmail, newCommit.Committer.Email)
|
||||
assert.Equal(t, expectedUserName, newCommit.Author.Name)
|
||||
assert.Equal(t, expectedEmail, newCommit.Author.Email)
|
||||
assert.Equal(t, expectedUserName, newCommit.Committer.Name)
|
||||
assert.Equal(t, expectedEmail, newCommit.Committer.Email)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -254,7 +254,7 @@ func TestWebGitCommitEmail(t *testing.T) {
|
||||
t.Run("EmailInvalid", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
email := unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{ID: 1, IsActivated: true})
|
||||
require.NotEqualValues(t, email.UID, user.ID)
|
||||
require.NotEqual(t, email.UID, user.ID)
|
||||
makeReq(t, "/user2/repo1/_edit/master/README.md", map[string]string{
|
||||
"tree_path": "README.md",
|
||||
"content": "test content",
|
||||
@@ -332,7 +332,7 @@ index 0000000000..bbbbbbbbbb
|
||||
)
|
||||
|
||||
// By the way, test the "cherrypick" page: a successful revert redirects to the main branch
|
||||
assert.EqualValues(t, "/user2/repo1/src/branch/master", resp1.Header().Get("Location"))
|
||||
assert.Equal(t, "/user2/repo1/src/branch/master", resp1.Header().Get("Location"))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ func TestEmptyRepoAddFileByAPI(t *testing.T) {
|
||||
var fileResponse api.FileResponse
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
expectedHTMLURL := setting.AppURL + "user30/empty/src/branch/new_branch/new-file.txt"
|
||||
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/empty/src/branch/new_branch/new-file.txt")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
|
@@ -29,7 +29,7 @@ func TestFeedRepo(t *testing.T) {
|
||||
assert.Contains(t, rss.Channel.Link, "/user2/repo1")
|
||||
assert.NotEmpty(t, rss.Channel.PubDate)
|
||||
assert.Len(t, rss.Channel.Items, 1)
|
||||
assert.EqualValues(t, "issue5", rss.Channel.Items[0].Description)
|
||||
assert.Equal(t, "issue5", rss.Channel.Items[0].Description)
|
||||
assert.NotEmpty(t, rss.Channel.Items[0].PubDate)
|
||||
})
|
||||
}
|
||||
|
@@ -483,7 +483,7 @@ func doProtectBranch(ctx APITestContext, branch, userToWhitelistPush, userToWhit
|
||||
|
||||
// Check if master branch has been locked successfully
|
||||
flashMsg := ctx.Session.GetCookieFlashMessage()
|
||||
assert.EqualValues(t, `Branch protection for rule "`+branch+`" has been updated.`, flashMsg.SuccessMsg)
|
||||
assert.Equal(t, `Branch protection for rule "`+branch+`" has been updated.`, flashMsg.SuccessMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -170,7 +170,7 @@ func runTestGitPush(t *testing.T, u *url.URL, gitOperation func(t *testing.T, gi
|
||||
|
||||
dbBranches := make([]*git_model.Branch, 0)
|
||||
require.NoError(t, db.GetEngine(db.DefaultContext).Where("repo_id=?", repo.ID).Find(&dbBranches))
|
||||
assert.Equalf(t, len(pushedBranches), len(dbBranches), "mismatched number of branches in db")
|
||||
assert.Lenf(t, dbBranches, len(pushedBranches), "mismatched number of branches in db")
|
||||
dbBranchesMap := make(map[string]*git_model.Branch, len(dbBranches))
|
||||
for _, branch := range dbBranches {
|
||||
dbBranchesMap[branch.Name] = branch
|
||||
|
@@ -72,7 +72,7 @@ func testGitSmartHTTP(t *testing.T, u *url.URL) {
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.EqualValues(t, kase.code, resp.StatusCode)
|
||||
assert.Equal(t, kase.code, resp.StatusCode)
|
||||
_, err = io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
@@ -99,26 +99,14 @@ func TestGPGGit(t *testing.T) {
|
||||
testCtx := NewAPITestContext(t, username, "initial-unsigned", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
||||
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
|
||||
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
|
||||
assert.NotNil(t, response.Verification)
|
||||
if response.Verification == nil {
|
||||
assert.FailNow(t, "no verification provided with response! %v", response)
|
||||
}
|
||||
assert.True(t, response.Verification.Verified)
|
||||
if !response.Verification.Verified {
|
||||
t.FailNow()
|
||||
}
|
||||
require.NotNil(t, response.Verification, "no verification provided with response! %v", response)
|
||||
require.True(t, response.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
|
||||
}))
|
||||
t.Run("CreateCRUDFile-ParentSigned-always", crudActionCreateFile(
|
||||
t, testCtx, user, "parentsigned", "parentsigned-always", "signed-parent2.txt", func(t *testing.T, response api.FileResponse) {
|
||||
assert.NotNil(t, response.Verification)
|
||||
if response.Verification == nil {
|
||||
assert.FailNow(t, "no verification provided with response! %v", response)
|
||||
}
|
||||
assert.True(t, response.Verification.Verified)
|
||||
if !response.Verification.Verified {
|
||||
t.FailNow()
|
||||
}
|
||||
require.NotNil(t, response.Verification, "no verification provided with response! %v", response)
|
||||
require.True(t, response.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
|
||||
}))
|
||||
})
|
||||
@@ -129,14 +117,8 @@ func TestGPGGit(t *testing.T) {
|
||||
testCtx := NewAPITestContext(t, username, "initial-unsigned", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
||||
t.Run("CreateCRUDFile-Always-ParentSigned", crudActionCreateFile(
|
||||
t, testCtx, user, "always", "always-parentsigned", "signed-always-parentsigned.txt", func(t *testing.T, response api.FileResponse) {
|
||||
assert.NotNil(t, response.Verification)
|
||||
if response.Verification == nil {
|
||||
assert.FailNow(t, "no verification provided with response! %v", response)
|
||||
}
|
||||
assert.True(t, response.Verification.Verified)
|
||||
if !response.Verification.Verified {
|
||||
t.FailNow()
|
||||
}
|
||||
require.NotNil(t, response.Verification, "no verification provided with response! %v", response)
|
||||
require.True(t, response.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
|
||||
}))
|
||||
})
|
||||
@@ -147,18 +129,9 @@ func TestGPGGit(t *testing.T) {
|
||||
testCtx := NewAPITestContext(t, username, "initial-always", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
||||
t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
|
||||
t.Run("CheckMasterBranchSigned", doAPIGetBranch(testCtx, "master", func(t *testing.T, branch api.Branch) {
|
||||
assert.NotNil(t, branch.Commit)
|
||||
if branch.Commit == nil {
|
||||
assert.FailNow(t, "no commit provided with branch! %v", branch)
|
||||
}
|
||||
assert.NotNil(t, branch.Commit.Verification)
|
||||
if branch.Commit.Verification == nil {
|
||||
assert.FailNow(t, "no verification provided with branch commit! %v", branch.Commit)
|
||||
}
|
||||
assert.True(t, branch.Commit.Verification.Verified)
|
||||
if !branch.Commit.Verification.Verified {
|
||||
t.FailNow()
|
||||
}
|
||||
require.NotNil(t, branch.Commit, "no commit provided with branch! %v", branch)
|
||||
require.NotNil(t, branch.Commit.Verification, "no verification provided with branch commit! %v", branch.Commit)
|
||||
require.True(t, branch.Commit.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", branch.Commit.Verification.Signer.Email)
|
||||
}))
|
||||
})
|
||||
@@ -181,11 +154,7 @@ func TestGPGGit(t *testing.T) {
|
||||
t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
|
||||
t.Run("CreateCRUDFile-ParentSigned", crudActionCreateFile(
|
||||
t, testCtx, user, "master", "parentsigned", "signed-parent.txt", func(t *testing.T, response api.FileResponse) {
|
||||
assert.True(t, response.Verification.Verified)
|
||||
if !response.Verification.Verified {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
require.True(t, response.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
|
||||
}))
|
||||
})
|
||||
@@ -197,11 +166,7 @@ func TestGPGGit(t *testing.T) {
|
||||
t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
|
||||
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
|
||||
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
|
||||
assert.True(t, response.Verification.Verified)
|
||||
if !response.Verification.Verified {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
require.True(t, response.Verification.Verified)
|
||||
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
|
||||
}))
|
||||
})
|
||||
|
@@ -50,12 +50,12 @@ func TestIncomingEmail(t *testing.T) {
|
||||
ref, err := incoming_payload.GetReferenceFromPayload(db.DefaultContext, issuePayload)
|
||||
assert.NoError(t, err)
|
||||
assert.IsType(t, ref, new(issues_model.Issue))
|
||||
assert.EqualValues(t, issue.ID, ref.(*issues_model.Issue).ID)
|
||||
assert.Equal(t, issue.ID, ref.(*issues_model.Issue).ID)
|
||||
|
||||
ref, err = incoming_payload.GetReferenceFromPayload(db.DefaultContext, commentPayload)
|
||||
assert.NoError(t, err)
|
||||
assert.IsType(t, ref, new(issues_model.Comment))
|
||||
assert.EqualValues(t, comment.ID, ref.(*issues_model.Comment).ID)
|
||||
assert.Equal(t, comment.ID, ref.(*issues_model.Comment).ID)
|
||||
})
|
||||
|
||||
t.Run("Token", func(t *testing.T) {
|
||||
|
@@ -360,7 +360,7 @@ func MakeRequestNilResponseRecorder(t testing.TB, rw *RequestWrapper, expectedSt
|
||||
recorder := NewNilResponseRecorder()
|
||||
testWebRoutes.ServeHTTP(recorder, req)
|
||||
if expectedStatus != NoExpectedStatus {
|
||||
if !assert.EqualValues(t, expectedStatus, recorder.Code,
|
||||
if !assert.Equal(t, expectedStatus, recorder.Code,
|
||||
"Request: %s %s", req.Method, req.URL.String()) {
|
||||
logUnexpectedResponse(t, &recorder.ResponseRecorder)
|
||||
}
|
||||
@@ -374,7 +374,7 @@ func MakeRequestNilResponseHashSumRecorder(t testing.TB, rw *RequestWrapper, exp
|
||||
recorder := NewNilResponseHashSumRecorder()
|
||||
testWebRoutes.ServeHTTP(recorder, req)
|
||||
if expectedStatus != NoExpectedStatus {
|
||||
if !assert.EqualValues(t, expectedStatus, recorder.Code,
|
||||
if !assert.Equal(t, expectedStatus, recorder.Code,
|
||||
"Request: %s %s", req.Method, req.URL.String()) {
|
||||
logUnexpectedResponse(t, &recorder.ResponseRecorder)
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ import (
|
||||
|
||||
func getIssuesSelection(t testing.TB, htmlDoc *HTMLDoc) *goquery.Selection {
|
||||
issueList := htmlDoc.doc.Find("#issue-list")
|
||||
assert.EqualValues(t, 1, issueList.Length())
|
||||
assert.Equal(t, 1, issueList.Length())
|
||||
return issueList.Find(".flex-item").Find(".issue-title")
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ func TestViewIssuesSortByType(t *testing.T) {
|
||||
if expectedNumIssues > setting.UI.IssuePagingNum {
|
||||
expectedNumIssues = setting.UI.IssuePagingNum
|
||||
}
|
||||
assert.EqualValues(t, expectedNumIssues, issuesSelection.Length())
|
||||
assert.Equal(t, expectedNumIssues, issuesSelection.Length())
|
||||
|
||||
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
|
||||
issue := getIssue(t, repo.ID, selection)
|
||||
assert.EqualValues(t, user.ID, issue.PosterID)
|
||||
assert.Equal(t, user.ID, issue.PosterID)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestViewIssuesKeyword(t *testing.T) {
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
issuesSelection := getIssuesSelection(t, htmlDoc)
|
||||
assert.EqualValues(t, 1, issuesSelection.Length())
|
||||
assert.Equal(t, 1, issuesSelection.Length())
|
||||
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
|
||||
issue := getIssue(t, repo.ID, selection)
|
||||
assert.False(t, issue.IsClosed)
|
||||
@@ -510,7 +510,7 @@ func TestSearchIssues(t *testing.T) {
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 20)
|
||||
|
||||
query.Add("limit", "5")
|
||||
@@ -518,7 +518,7 @@ func TestSearchIssues(t *testing.T) {
|
||||
req = NewRequest(t, "GET", link.String())
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
|
||||
assert.Len(t, apiIssues, 5)
|
||||
|
||||
query = url.Values{"assigned": {"true"}, "state": {"all"}}
|
||||
@@ -645,7 +645,7 @@ func TestGetIssueInfo(t *testing.T) {
|
||||
}
|
||||
DecodeJSON(t, resp, &respStruct)
|
||||
|
||||
assert.EqualValues(t, issue.ID, respStruct.ConvertedIssue.ID)
|
||||
assert.Equal(t, issue.ID, respStruct.ConvertedIssue.ID)
|
||||
assert.Contains(t, string(respStruct.RenderedLabels), `"labels-list"`)
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ func TestUpdateIssueDeadline(t *testing.T) {
|
||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{"deadline": "2022-04-06"})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
issueAfter := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 10})
|
||||
assert.EqualValues(t, "2022-04-06", issueAfter.DeadlineUnix.FormatDate())
|
||||
assert.Equal(t, "2022-04-06", issueAfter.DeadlineUnix.FormatDate())
|
||||
|
||||
req = NewRequestWithValues(t, "POST", urlStr, map[string]string{"deadline": ""})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
@@ -686,8 +686,8 @@ func TestIssueReferenceURL(t *testing.T) {
|
||||
|
||||
// the "reference" uses relative URLs, then JS code will convert them to absolute URLs for current origin, in case users are using multiple domains
|
||||
ref, _ := htmlDoc.Find(`.timeline-item.comment.first .reference-issue`).Attr("data-reference")
|
||||
assert.EqualValues(t, "/user2/repo1/issues/1#issue-1", ref)
|
||||
assert.Equal(t, "/user2/repo1/issues/1#issue-1", ref)
|
||||
|
||||
ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.first) .reference-issue`).Attr("data-reference")
|
||||
assert.EqualValues(t, "/user2/repo1/issues/1#issuecomment-2", ref)
|
||||
assert.Equal(t, "/user2/repo1/issues/1#issuecomment-2", ref)
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ func TestRedirectsNoLogin(t *testing.T) {
|
||||
for _, c := range redirects {
|
||||
req := NewRequest(t, "GET", c.from)
|
||||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.EqualValues(t, path.Join(setting.AppSubURL, c.to), test.RedirectURL(resp))
|
||||
assert.Equal(t, path.Join(setting.AppSubURL, c.to), test.RedirectURL(resp))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ func TestExternalMarkupRenderer(t *testing.T) {
|
||||
|
||||
req := NewRequest(t, "GET", "/user30/renderer/src/branch/master/README.html")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
assert.Equal(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
|
||||
bs, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
@@ -36,25 +36,25 @@ func TestExternalMarkupRenderer(t *testing.T) {
|
||||
div := doc.Find("div.file-view")
|
||||
data, err := div.Html()
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "<div>\n\ttest external renderer\n</div>", strings.TrimSpace(data))
|
||||
assert.Equal(t, "<div>\n\ttest external renderer\n</div>", strings.TrimSpace(data))
|
||||
|
||||
r := markup.GetRendererByFileName("a.html").(*external.Renderer)
|
||||
r.RenderContentMode = setting.RenderContentModeIframe
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/renderer/src/branch/master/README.html")
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
assert.Equal(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
bs, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
doc = NewHTMLParser(t, bytes.NewBuffer(bs))
|
||||
iframe := doc.Find("iframe")
|
||||
assert.EqualValues(t, "/user30/renderer/render/branch/master/README.html", iframe.AttrOr("src", ""))
|
||||
assert.Equal(t, "/user30/renderer/render/branch/master/README.html", iframe.AttrOr("src", ""))
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/renderer/render/branch/master/README.html")
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
assert.Equal(t, "text/html; charset=utf-8", resp.Header().Get("Content-Type"))
|
||||
bs, err = io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "frame-src 'self'; sandbox allow-scripts", resp.Header().Get("Content-Security-Policy"))
|
||||
assert.EqualValues(t, "<div>\n\ttest external renderer\n</div>\n", string(bs))
|
||||
assert.Equal(t, "frame-src 'self'; sandbox allow-scripts", resp.Header().Get("Content-Security-Policy"))
|
||||
assert.Equal(t, "<div>\n\ttest external renderer\n</div>\n", string(bs))
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ func TestMigrateGiteaForm(t *testing.T) {
|
||||
assert.True(t, exists, "The template has changed")
|
||||
serviceInput, exists := form.Find(`input[name="service"]`).Attr("value")
|
||||
assert.True(t, exists)
|
||||
assert.EqualValues(t, fmt.Sprintf("%d", structs.GiteaService), serviceInput)
|
||||
assert.Equal(t, fmt.Sprintf("%d", structs.GiteaService), serviceInput)
|
||||
// Step 4: submit the migration to only migrate issues
|
||||
migratedRepoName := "otherrepo"
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
@@ -100,7 +100,7 @@ func TestMigrateGiteaForm(t *testing.T) {
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
// Step 5: a redirection displays the migrated repository
|
||||
loc := resp.Header().Get("Location")
|
||||
assert.EqualValues(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), loc)
|
||||
assert.Equal(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), loc)
|
||||
// Step 6: check the repo was created
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName})
|
||||
})
|
||||
|
@@ -99,7 +99,7 @@ func TestMirrorPull(t *testing.T) {
|
||||
|
||||
count, err := db.Count[repo_model.Release](db.DefaultContext, findOptions)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, initCount+1, count)
|
||||
assert.Equal(t, initCount+1, count)
|
||||
|
||||
release, err := repo_model.GetRelease(db.DefaultContext, repo.ID, "v0.2")
|
||||
assert.NoError(t, err)
|
||||
@@ -110,5 +110,5 @@ func TestMirrorPull(t *testing.T) {
|
||||
|
||||
count, err = db.Count[repo_model.Release](db.DefaultContext, findOptions)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, initCount, count)
|
||||
assert.Equal(t, initCount, count)
|
||||
}
|
||||
|
@@ -128,18 +128,18 @@ func TestRepoSettingPushMirrorUpdate(t *testing.T) {
|
||||
pushMirrors, cnt, err := repo_model.GetPushMirrorsByRepoID(db.DefaultContext, repo2.ID, db.ListOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
assert.EqualValues(t, 24*time.Hour, pushMirrors[0].Interval)
|
||||
assert.Equal(t, 24*time.Hour, pushMirrors[0].Interval)
|
||||
repo2PushMirrorID := pushMirrors[0].ID
|
||||
|
||||
// update repo2 push mirror
|
||||
assert.True(t, doUpdatePushMirror(t, session, "user2", "repo2", repo2PushMirrorID, "10m0s"))
|
||||
pushMirror := unittest.AssertExistsAndLoadBean(t, &repo_model.PushMirror{ID: repo2PushMirrorID})
|
||||
assert.EqualValues(t, 10*time.Minute, pushMirror.Interval)
|
||||
assert.Equal(t, 10*time.Minute, pushMirror.Interval)
|
||||
|
||||
// avoid updating repo2 push mirror from repo1
|
||||
assert.False(t, doUpdatePushMirror(t, session, "user2", "repo1", repo2PushMirrorID, "20m0s"))
|
||||
pushMirror = unittest.AssertExistsAndLoadBean(t, &repo_model.PushMirror{ID: repo2PushMirrorID})
|
||||
assert.EqualValues(t, 10*time.Minute, pushMirror.Interval) // not changed
|
||||
assert.Equal(t, 10*time.Minute, pushMirror.Interval) // not changed
|
||||
|
||||
// avoid deleting repo2 push mirror from repo1
|
||||
assert.False(t, doRemovePushMirror(t, session, "user2", "repo1", repo2PushMirrorID))
|
||||
|
@@ -41,7 +41,7 @@ func TestOrgRepos(t *testing.T) {
|
||||
sel := htmlDoc.doc.Find("a.name")
|
||||
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()))
|
||||
assert.Equal(t, repos[i], strings.TrimSpace(sel.Eq(i).Text()))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@@ -79,9 +79,9 @@ func TestMoveRepoProjectColumns(t *testing.T) {
|
||||
columnsAfter, err := project1.GetColumns(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, columnsAfter, 3)
|
||||
assert.EqualValues(t, columns[1].ID, columnsAfter[0].ID)
|
||||
assert.EqualValues(t, columns[2].ID, columnsAfter[1].ID)
|
||||
assert.EqualValues(t, columns[0].ID, columnsAfter[2].ID)
|
||||
assert.Equal(t, columns[1].ID, columnsAfter[0].ID)
|
||||
assert.Equal(t, columns[2].ID, columnsAfter[1].ID)
|
||||
assert.Equal(t, columns[0].ID, columnsAfter[2].ID)
|
||||
|
||||
assert.NoError(t, project_model.DeleteProjectByID(db.DefaultContext, project1.ID))
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ func TestPullCompare(t *testing.T) {
|
||||
assert.True(t, exists, "The template has changed")
|
||||
req = NewRequest(t, "GET", link)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.EqualValues(t, http.StatusOK, resp.Code)
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
|
||||
// test the edit button in the PR diff view
|
||||
req = NewRequest(t, "GET", "/user2/repo1/pulls/3/files")
|
||||
@@ -86,7 +86,7 @@ func TestPullCompare(t *testing.T) {
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
doc = NewHTMLParser(t, resp.Body)
|
||||
editButtonCount = doc.doc.Find(".diff-file-header-actions a[href*='/_edit/']").Length()
|
||||
assert.EqualValues(t, 0, editButtonCount, "Expected not to find a button to edit a file in the PR diff view because head repository has been deleted")
|
||||
assert.Equal(t, 0, editButtonCount, "Expected not to find a button to edit a file in the PR diff view because head repository has been deleted")
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
|
||||
}{}
|
||||
DecodeJSON(t, resp, &respJSON)
|
||||
|
||||
assert.EqualValues(t, fmt.Sprintf("/%s/%s/pulls/%s", user, repo, pullnum), respJSON.Redirect)
|
||||
assert.Equal(t, fmt.Sprintf("/%s/%s/pulls/%s", user, repo, pullnum), respJSON.Redirect)
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func TestPullMerge(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
|
||||
|
||||
hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1)
|
||||
@@ -122,7 +122,7 @@ func TestPullRebase(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebase, false)
|
||||
|
||||
hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1)
|
||||
@@ -144,7 +144,7 @@ func TestPullRebaseMerge(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebaseMerge, false)
|
||||
|
||||
hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1)
|
||||
@@ -167,7 +167,7 @@ func TestPullSquash(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash, false)
|
||||
|
||||
hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1)
|
||||
@@ -185,7 +185,7 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "feature/test", "This is a pull title")
|
||||
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
|
||||
|
||||
// Check PR branch deletion
|
||||
@@ -198,7 +198,7 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
|
||||
assert.NotEmpty(t, respJSON.Redirect, "Redirected URL is not found")
|
||||
|
||||
elem = strings.Split(respJSON.Redirect, "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
|
||||
// Check branch deletion result
|
||||
req := NewRequest(t, "GET", respJSON.Redirect)
|
||||
@@ -207,7 +207,7 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
resultMsg := htmlDoc.doc.Find(".ui.message>p").Text()
|
||||
|
||||
assert.EqualValues(t, "Branch \"user1/repo1:feature/test\" has been deleted.", resultMsg)
|
||||
assert.Equal(t, "Branch \"user1/repo1:feature/test\" has been deleted.", resultMsg)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -544,11 +544,11 @@ func TestPullRetargetChildOnBranchDelete(t *testing.T) {
|
||||
|
||||
respBasePR := testPullCreate(t, session, "user2", "repo1", true, "master", "base-pr", "Base Pull Request")
|
||||
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
|
||||
assert.EqualValues(t, "pulls", elemBasePR[3])
|
||||
assert.Equal(t, "pulls", elemBasePR[3])
|
||||
|
||||
respChildPR := testPullCreate(t, session, "user1", "repo1", false, "base-pr", "child-pr", "Child Pull Request")
|
||||
elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/")
|
||||
assert.EqualValues(t, "pulls", elemChildPR[3])
|
||||
assert.Equal(t, "pulls", elemChildPR[3])
|
||||
|
||||
testPullMerge(t, session, elemBasePR[1], elemBasePR[2], elemBasePR[4], repo_model.MergeStyleMerge, true)
|
||||
|
||||
@@ -564,8 +564,8 @@ func TestPullRetargetChildOnBranchDelete(t *testing.T) {
|
||||
targetBranch := htmlDoc.doc.Find("#branch_target>a").Text()
|
||||
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
|
||||
|
||||
assert.EqualValues(t, "master", targetBranch)
|
||||
assert.EqualValues(t, "Open", prStatus)
|
||||
assert.Equal(t, "master", targetBranch)
|
||||
assert.Equal(t, "Open", prStatus)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -578,11 +578,11 @@ func TestPullDontRetargetChildOnWrongRepo(t *testing.T) {
|
||||
|
||||
respBasePR := testPullCreate(t, session, "user1", "repo1", false, "master", "base-pr", "Base Pull Request")
|
||||
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
|
||||
assert.EqualValues(t, "pulls", elemBasePR[3])
|
||||
assert.Equal(t, "pulls", elemBasePR[3])
|
||||
|
||||
respChildPR := testPullCreate(t, session, "user1", "repo1", true, "base-pr", "child-pr", "Child Pull Request")
|
||||
elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/")
|
||||
assert.EqualValues(t, "pulls", elemChildPR[3])
|
||||
assert.Equal(t, "pulls", elemChildPR[3])
|
||||
|
||||
defer test.MockVariableValue(&setting.Repository.PullRequest.RetargetChildrenOnMerge, false)()
|
||||
|
||||
@@ -601,8 +601,8 @@ func TestPullDontRetargetChildOnWrongRepo(t *testing.T) {
|
||||
targetBranch := htmlDoc.doc.Find("#branch_target>span").Text()
|
||||
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
|
||||
|
||||
assert.EqualValues(t, "base-pr", targetBranch)
|
||||
assert.EqualValues(t, "Closed", prStatus)
|
||||
assert.Equal(t, "base-pr", targetBranch)
|
||||
assert.Equal(t, "Closed", prStatus)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -614,7 +614,7 @@ func TestPullRequestMergedWithNoPermissionDeleteBranch(t *testing.T) {
|
||||
|
||||
respBasePR := testPullCreate(t, session, "user4", "repo1", false, "master", "base-pr", "Base Pull Request")
|
||||
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
|
||||
assert.EqualValues(t, "pulls", elemBasePR[3])
|
||||
assert.Equal(t, "pulls", elemBasePR[3])
|
||||
|
||||
// user2 has no permission to delete branch of repo user1/repo1
|
||||
session2 := loginUser(t, "user2")
|
||||
@@ -665,7 +665,7 @@ func TestPullMergeIndexerNotifier(t *testing.T) {
|
||||
|
||||
// merge the pull request
|
||||
elem := strings.Split(test.RedirectURL(createPullResp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
|
||||
|
||||
// check if the issue is closed
|
||||
@@ -699,7 +699,7 @@ func testResetRepo(t *testing.T, repoPath, branch, commitID string) {
|
||||
defer repo.Close()
|
||||
id, err := repo.GetBranchCommitID(branch)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, commitID, id)
|
||||
assert.Equal(t, commitID, id)
|
||||
}
|
||||
|
||||
func TestPullAutoMergeAfterCommitStatusSucceed(t *testing.T) {
|
||||
|
@@ -119,7 +119,7 @@ func TestPullView_CodeOwner(t *testing.T) {
|
||||
assert.Len(t, reviewNotifiers, 2)
|
||||
reviewerIDs := []int64{reviewNotifiers[0].Reviewer.ID, reviewNotifiers[1].Reviewer.ID}
|
||||
sort.Slice(reviewerIDs, func(i, j int) bool { return reviewerIDs[i] < reviewerIDs[j] })
|
||||
assert.EqualValues(t, []int64{5, 8}, reviewerIDs)
|
||||
assert.Equal(t, []int64{5, 8}, reviewerIDs)
|
||||
|
||||
reviewNotifiers, err = issue_service.PullRequestCodeOwnersReviewSpecialCommits(db.DefaultContext, pr, resp1.Commit.SHA, resp2.Commit.SHA)
|
||||
assert.NoError(t, err)
|
||||
@@ -130,13 +130,13 @@ func TestPullView_CodeOwner(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
prUpdated1 := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
|
||||
assert.NoError(t, prUpdated1.LoadIssue(db.DefaultContext))
|
||||
assert.EqualValues(t, "[WIP] Test Pull Request", prUpdated1.Issue.Title)
|
||||
assert.Equal(t, "[WIP] Test Pull Request", prUpdated1.Issue.Title)
|
||||
|
||||
err = issue_service.ChangeTitle(db.DefaultContext, prUpdated1.Issue, user2, "Test Pull Request2")
|
||||
assert.NoError(t, err)
|
||||
prUpdated2 := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
|
||||
assert.NoError(t, prUpdated2.LoadIssue(db.DefaultContext))
|
||||
assert.EqualValues(t, "Test Pull Request2", prUpdated2.Issue.Title)
|
||||
assert.Equal(t, "Test Pull Request2", prUpdated2.Issue.Title)
|
||||
})
|
||||
|
||||
// change the default branch CODEOWNERS file to change README.md's codeowner
|
||||
@@ -229,7 +229,7 @@ func TestPullView_GivenApproveOrRejectReviewOnClosedPR(t *testing.T) {
|
||||
testEditFile(t, user1Session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
|
||||
resp := testPullCreate(t, user1Session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, user1Session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
|
||||
|
||||
// Grab the CSRF token.
|
||||
@@ -249,7 +249,7 @@ func TestPullView_GivenApproveOrRejectReviewOnClosedPR(t *testing.T) {
|
||||
testEditFileToNewBranch(t, user1Session, "user1", "repo1", "master", "a-test-branch", "README.md", "Hello, World (Editied...again)\n")
|
||||
resp := testPullCreate(t, user1Session, "user1", "repo1", false, "master", "a-test-branch", "This is a pull title")
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testIssueClose(t, user1Session, elem[1], elem[2], elem[4])
|
||||
|
||||
// Grab the CSRF token.
|
||||
|
@@ -86,7 +86,7 @@ func TestPullCreate_CommitStatus(t *testing.T) {
|
||||
commitURL, exists = doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href")
|
||||
assert.True(t, exists)
|
||||
assert.NotEmpty(t, commitURL)
|
||||
assert.EqualValues(t, commitID, path.Base(commitURL))
|
||||
assert.Equal(t, commitID, path.Base(commitURL))
|
||||
|
||||
cls, ok := doc.doc.Find("#commits-table tbody tr td.message .commit-status").Last().Attr("class")
|
||||
assert.True(t, ok)
|
||||
@@ -95,7 +95,7 @@ func TestPullCreate_CommitStatus(t *testing.T) {
|
||||
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user1", Name: "repo1"})
|
||||
css := unittest.AssertExistsAndLoadBean(t, &git_model.CommitStatusSummary{RepoID: repo1.ID, SHA: commitID})
|
||||
assert.EqualValues(t, api.CommitStatusWarning, css.State)
|
||||
assert.Equal(t, api.CommitStatusWarning, css.State)
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -33,8 +33,8 @@ func TestAPIPullUpdate(t *testing.T) {
|
||||
// Test GetDiverging
|
||||
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, diffCount.Behind)
|
||||
assert.EqualValues(t, 1, diffCount.Ahead)
|
||||
assert.Equal(t, 1, diffCount.Behind)
|
||||
assert.Equal(t, 1, diffCount.Ahead)
|
||||
assert.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
|
||||
assert.NoError(t, pr.LoadIssue(db.DefaultContext))
|
||||
|
||||
@@ -47,8 +47,8 @@ func TestAPIPullUpdate(t *testing.T) {
|
||||
// Test GetDiverging after update
|
||||
diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, diffCount.Behind)
|
||||
assert.EqualValues(t, 2, diffCount.Ahead)
|
||||
assert.Equal(t, 0, diffCount.Behind)
|
||||
assert.Equal(t, 2, diffCount.Ahead)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ func TestAPIPullUpdateByRebase(t *testing.T) {
|
||||
// Test GetDiverging
|
||||
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, diffCount.Behind)
|
||||
assert.EqualValues(t, 1, diffCount.Ahead)
|
||||
assert.Equal(t, 1, diffCount.Behind)
|
||||
assert.Equal(t, 1, diffCount.Ahead)
|
||||
assert.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
|
||||
assert.NoError(t, pr.LoadIssue(db.DefaultContext))
|
||||
|
||||
@@ -76,8 +76,8 @@ func TestAPIPullUpdateByRebase(t *testing.T) {
|
||||
// Test GetDiverging after update
|
||||
diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, diffCount.Behind)
|
||||
assert.EqualValues(t, 1, diffCount.Ahead)
|
||||
assert.Equal(t, 0, diffCount.Behind)
|
||||
assert.Equal(t, 1, diffCount.Ahead)
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -54,12 +54,12 @@ func checkLatestReleaseAndCount(t *testing.T, session *TestSession, repoURL, ver
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
labelText := htmlDoc.doc.Find("#release-list > li .detail .label").First().Text()
|
||||
assert.EqualValues(t, label, labelText)
|
||||
assert.Equal(t, label, labelText)
|
||||
titleText := htmlDoc.doc.Find("#release-list > li .detail h4 a").First().Text()
|
||||
assert.EqualValues(t, version, titleText)
|
||||
assert.Equal(t, version, titleText)
|
||||
|
||||
releaseList := htmlDoc.doc.Find("#release-list > li")
|
||||
assert.EqualValues(t, count, releaseList.Length())
|
||||
assert.Equal(t, count, releaseList.Length())
|
||||
}
|
||||
|
||||
func TestViewReleases(t *testing.T) {
|
||||
@@ -157,14 +157,14 @@ func TestViewReleaseListNoLogin(t *testing.T) {
|
||||
commitsToMain = append(commitsToMain, s.Find(".ahead > a").Text())
|
||||
})
|
||||
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"/user2/repo-release/releases/tag/empty-target-branch",
|
||||
"/user2/repo-release/releases/tag/non-existing-target-branch",
|
||||
"/user2/repo-release/releases/tag/v2.0",
|
||||
"/user2/repo-release/releases/tag/v1.1",
|
||||
"/user2/repo-release/releases/tag/v1.0",
|
||||
}, links)
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"1 commits", // like v1.1
|
||||
"1 commits", // like v1.1
|
||||
"0 commits",
|
||||
@@ -182,8 +182,8 @@ func TestViewSingleRelease(t *testing.T) {
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
// check the "number of commits to main since this release"
|
||||
releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
|
||||
assert.EqualValues(t, 1, releaseList.Length())
|
||||
assert.EqualValues(t, "3 commits", releaseList.First().Text())
|
||||
assert.Equal(t, 1, releaseList.Length())
|
||||
assert.Equal(t, "3 commits", releaseList.First().Text())
|
||||
})
|
||||
t.Run("Login", func(t *testing.T) {
|
||||
session := loginUser(t, "user1")
|
||||
@@ -218,7 +218,7 @@ func TestViewReleaseListLogin(t *testing.T) {
|
||||
links = append(links, link)
|
||||
})
|
||||
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"/user2/repo1/releases/tag/draft-release",
|
||||
"/user2/repo1/releases/tag/v1.0",
|
||||
"/user2/repo1/releases/tag/v1.1",
|
||||
@@ -245,7 +245,7 @@ func TestViewTagsList(t *testing.T) {
|
||||
tagNames = append(tagNames, s.Text())
|
||||
})
|
||||
|
||||
assert.EqualValues(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
|
||||
assert.Equal(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
|
||||
}
|
||||
|
||||
func TestDownloadReleaseAttachment(t *testing.T) {
|
||||
|
@@ -24,7 +24,7 @@ func TestRepoActivity(t *testing.T) {
|
||||
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
elem := strings.Split(test.RedirectURL(resp), "/")
|
||||
assert.EqualValues(t, "pulls", elem[3])
|
||||
assert.Equal(t, "pulls", elem[3])
|
||||
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
|
||||
|
||||
testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n")
|
||||
|
@@ -23,7 +23,7 @@ func testRepoCommitsSearch(t *testing.T, query, commit string) {
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
sel := doc.doc.Find("#commits-table tbody tr td.sha a")
|
||||
assert.EqualValues(t, commit, strings.TrimSpace(sel.Text()))
|
||||
assert.Equal(t, commit, strings.TrimSpace(sel.Text()))
|
||||
}
|
||||
|
||||
func TestRepoCommitsSearch(t *testing.T) {
|
||||
|
@@ -58,9 +58,9 @@ func Test_ReposGitCommitListNotMaster(t *testing.T) {
|
||||
})
|
||||
|
||||
assert.Len(t, commits, 3)
|
||||
assert.EqualValues(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", commits[0])
|
||||
assert.EqualValues(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", commits[1])
|
||||
assert.EqualValues(t, "5099b81332712fe655e34e8dd63574f503f61811", commits[2])
|
||||
assert.Equal(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", commits[0])
|
||||
assert.Equal(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", commits[1])
|
||||
assert.Equal(t, "5099b81332712fe655e34e8dd63574f503f61811", commits[2])
|
||||
|
||||
userNames := []string{}
|
||||
doc.doc.Find("#commits-table .author-wrapper").Each(func(i int, s *goquery.Selection) {
|
||||
@@ -71,9 +71,9 @@ func Test_ReposGitCommitListNotMaster(t *testing.T) {
|
||||
})
|
||||
|
||||
assert.Len(t, userNames, 3)
|
||||
assert.EqualValues(t, "User2", userNames[0])
|
||||
assert.EqualValues(t, "user21", userNames[1])
|
||||
assert.EqualValues(t, "User2", userNames[2])
|
||||
assert.Equal(t, "User2", userNames[0])
|
||||
assert.Equal(t, "user21", userNames[1])
|
||||
assert.Equal(t, "User2", userNames[2])
|
||||
}
|
||||
|
||||
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
||||
@@ -141,7 +141,7 @@ func testRepoCommitsWithStatus(t *testing.T, resp, respOne *httptest.ResponseRec
|
||||
assert.Equal(t, api.CommitStatusState(state), statuses[0].State)
|
||||
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", statuses[0].URL)
|
||||
assert.Equal(t, "http://test.ci/", statuses[0].TargetURL)
|
||||
assert.Equal(t, "", statuses[0].Description)
|
||||
assert.Empty(t, statuses[0].Description)
|
||||
assert.Equal(t, "testci", statuses[0].Context)
|
||||
|
||||
assert.Len(t, status.Statuses, 1)
|
||||
|
@@ -88,7 +88,7 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
|
||||
// fork to a limited org
|
||||
limitedOrg := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 22})
|
||||
assert.EqualValues(t, structs.VisibleTypeLimited, limitedOrg.Visibility)
|
||||
assert.Equal(t, structs.VisibleTypeLimited, limitedOrg.Visibility)
|
||||
ownerTeam1, err := org_model.OrgFromUser(limitedOrg).GetOwnerTeam(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam1, user1))
|
||||
@@ -98,7 +98,7 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
user4Sess := loginUser(t, "user4")
|
||||
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user4"})
|
||||
privateOrg := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 23})
|
||||
assert.EqualValues(t, structs.VisibleTypePrivate, privateOrg.Visibility)
|
||||
assert.Equal(t, structs.VisibleTypePrivate, privateOrg.Visibility)
|
||||
ownerTeam2, err := org_model.OrgFromUser(privateOrg).GetOwnerTeam(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam2, user4))
|
||||
@@ -109,7 +109,7 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
req := NewRequest(t, "GET", "/user2/repo1/forks")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
assert.EqualValues(t, 0, htmlDoc.Find(forkItemSelector).Length())
|
||||
assert.Equal(t, 0, htmlDoc.Find(forkItemSelector).Length())
|
||||
})
|
||||
|
||||
t.Run("Logged in", func(t *testing.T) {
|
||||
@@ -119,11 +119,11 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||
resp := user1Sess.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
// since user1 is an admin, he can get both of the forked repositories
|
||||
assert.EqualValues(t, 2, htmlDoc.Find(forkItemSelector).Length())
|
||||
assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length())
|
||||
|
||||
assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam2, user1))
|
||||
resp = user1Sess.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
assert.EqualValues(t, 2, htmlDoc.Find(forkItemSelector).Length())
|
||||
assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length())
|
||||
})
|
||||
}
|
||||
|
@@ -57,5 +57,5 @@ func testSearch(t *testing.T, url string, expected []string) {
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
filenames := resultFilenames(NewHTMLParser(t, resp.Body))
|
||||
assert.EqualValues(t, expected, filenames)
|
||||
assert.Equal(t, expected, filenames)
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ func testViewRepoWithCache(t *testing.T) {
|
||||
})
|
||||
|
||||
commitT := time.Date(2017, time.June, 14, 13, 54, 21, 0, time.UTC).In(time.Local).Format(time.RFC1123)
|
||||
assert.EqualValues(t, []file{
|
||||
assert.Equal(t, []file{
|
||||
{
|
||||
fileName: "doc",
|
||||
commitID: "2a47ca4b614a9f5a43abbd5ad851a54a616ffee6",
|
||||
@@ -250,9 +250,9 @@ func testViewFileInRepo(t *testing.T) {
|
||||
repoTopics := htmlDoc.doc.Find("#repo-topics")
|
||||
repoSummary := htmlDoc.doc.Find(".repository-summary")
|
||||
|
||||
assert.EqualValues(t, 0, description.Length())
|
||||
assert.EqualValues(t, 0, repoTopics.Length())
|
||||
assert.EqualValues(t, 0, repoSummary.Length())
|
||||
assert.Equal(t, 0, description.Length())
|
||||
assert.Equal(t, 0, repoTopics.Length())
|
||||
assert.Equal(t, 0, repoSummary.Length())
|
||||
}
|
||||
|
||||
// TestBlameFileInRepo repo description, topics and summary should not be displayed when running blame on a file
|
||||
@@ -269,9 +269,9 @@ func testBlameFileInRepo(t *testing.T) {
|
||||
repoTopics := htmlDoc.doc.Find("#repo-topics")
|
||||
repoSummary := htmlDoc.doc.Find(".repository-summary")
|
||||
|
||||
assert.EqualValues(t, 0, description.Length())
|
||||
assert.EqualValues(t, 0, repoTopics.Length())
|
||||
assert.EqualValues(t, 0, repoSummary.Length())
|
||||
assert.Equal(t, 0, description.Length())
|
||||
assert.Equal(t, 0, repoTopics.Length())
|
||||
assert.Equal(t, 0, repoSummary.Length())
|
||||
}
|
||||
|
||||
// TestViewRepoDirectory repo description, topics and summary should not be displayed when within a directory
|
||||
|
@@ -25,7 +25,7 @@ func TestTopicSearch(t *testing.T) {
|
||||
res := MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 6)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// pagination search topics
|
||||
topics.TopicNames = nil
|
||||
@@ -35,7 +35,7 @@ func TestTopicSearch(t *testing.T) {
|
||||
res = MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 4)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// second page
|
||||
topics.TopicNames = nil
|
||||
@@ -45,7 +45,7 @@ func TestTopicSearch(t *testing.T) {
|
||||
res = MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
|
||||
DecodeJSON(t, res, &topics)
|
||||
assert.Len(t, topics.TopicNames, 2)
|
||||
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
|
||||
assert.Equal(t, "6", res.Header().Get("x-total-count"))
|
||||
|
||||
// add keyword search
|
||||
topics.TopicNames = nil
|
||||
@@ -63,7 +63,7 @@ func TestTopicSearch(t *testing.T) {
|
||||
DecodeJSON(t, res, &topics)
|
||||
if assert.Len(t, topics.TopicNames, 1) {
|
||||
assert.EqualValues(t, 2, topics.TopicNames[0].ID)
|
||||
assert.EqualValues(t, "database", topics.TopicNames[0].Name)
|
||||
assert.EqualValues(t, 1, topics.TopicNames[0].RepoCount)
|
||||
assert.Equal(t, "database", topics.TopicNames[0].Name)
|
||||
assert.Equal(t, 1, topics.TopicNames[0].RepoCount)
|
||||
}
|
||||
}
|
||||
|
@@ -149,11 +149,11 @@ func Test_WebhookCreate(t *testing.T) {
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, string(webhook_module.HookEventCreate), triggeredEvent)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.EqualValues(t, "master2", payloads[0].Ref)
|
||||
assert.EqualValues(t, "branch", payloads[0].RefType)
|
||||
assert.Equal(t, string(webhook_module.HookEventCreate), triggeredEvent)
|
||||
assert.Equal(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "master2", payloads[0].Ref)
|
||||
assert.Equal(t, "branch", payloads[0].RefType)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -181,12 +181,12 @@ func Test_WebhookDelete(t *testing.T) {
|
||||
testAPIDeleteBranch(t, "master2", http.StatusNoContent)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "delete", triggeredEvent)
|
||||
assert.Equal(t, "delete", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.EqualValues(t, "master2", payloads[0].Ref)
|
||||
assert.EqualValues(t, "branch", payloads[0].RefType)
|
||||
assert.Equal(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "master2", payloads[0].Ref)
|
||||
assert.Equal(t, "branch", payloads[0].RefType)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ func Test_WebhookFork(t *testing.T) {
|
||||
testRepoFork(t, session, "user2", "repo1", "user1", "repo1-fork", "master")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "fork", triggeredEvent)
|
||||
assert.Equal(t, "fork", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "repo1-fork", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user1/repo1-fork", payloads[0].Repo.FullName)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Forkee.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Forkee.FullName)
|
||||
assert.Equal(t, "repo1-fork", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user1/repo1-fork", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "repo1", payloads[0].Forkee.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Forkee.FullName)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -246,14 +246,14 @@ func Test_WebhookIssueComment(t *testing.T) {
|
||||
testIssueAddComment(t, session, issueURL, "issue title2 comment1", "")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "issue_comment", triggeredEvent)
|
||||
assert.Equal(t, "issue_comment", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.EqualValues(t, "Title2", payloads[0].Issue.Title)
|
||||
assert.EqualValues(t, "Description2", payloads[0].Issue.Body)
|
||||
assert.EqualValues(t, "issue title2 comment1", payloads[0].Comment.Body)
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "Title2", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "Description2", payloads[0].Issue.Body)
|
||||
assert.Equal(t, "issue title2 comment1", payloads[0].Comment.Body)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -280,11 +280,11 @@ func Test_WebhookRelease(t *testing.T) {
|
||||
createNewRelease(t, session, "/user2/repo1", "v0.0.99", "v0.0.99", false, false)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "release", triggeredEvent)
|
||||
assert.Equal(t, "release", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repository.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repository.FullName)
|
||||
assert.EqualValues(t, "v0.0.99", payloads[0].Release.TagName)
|
||||
assert.Equal(t, "repo1", payloads[0].Repository.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repository.FullName)
|
||||
assert.Equal(t, "v0.0.99", payloads[0].Release.TagName)
|
||||
assert.False(t, payloads[0].Release.IsDraft)
|
||||
assert.False(t, payloads[0].Release.IsPrerelease)
|
||||
})
|
||||
@@ -313,12 +313,12 @@ func Test_WebhookPush(t *testing.T) {
|
||||
testCreateFile(t, session, "user2", "repo1", "master", "test_webhook_push.md", "# a test file for webhook push")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "push", triggeredEvent)
|
||||
assert.Equal(t, "push", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Len(t, payloads[0].Commits, 1)
|
||||
assert.EqualValues(t, []string{"test_webhook_push.md"}, payloads[0].Commits[0].Added)
|
||||
assert.Equal(t, []string{"test_webhook_push.md"}, payloads[0].Commits[0].Added)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -345,13 +345,13 @@ func Test_WebhookIssue(t *testing.T) {
|
||||
testNewIssue(t, session, "user2", "repo1", "Title1", "Description1")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "issues", triggeredEvent)
|
||||
assert.Equal(t, "issues", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "opened", payloads[0].Action)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.EqualValues(t, "Title1", payloads[0].Issue.Title)
|
||||
assert.EqualValues(t, "Description1", payloads[0].Issue.Body)
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "Title1", payloads[0].Issue.Title)
|
||||
assert.Equal(t, "Description1", payloads[0].Issue.Body)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -380,15 +380,15 @@ func Test_WebhookPullRequest(t *testing.T) {
|
||||
testCreatePullToDefaultBranch(t, session, repo1, repo1, "master2", "first pull request")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "pull_request", triggeredEvent)
|
||||
assert.Equal(t, "pull_request", triggeredEvent)
|
||||
require.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "repo1", payloads[0].PullRequest.Base.Repository.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].PullRequest.Base.Repository.FullName)
|
||||
assert.EqualValues(t, "repo1", payloads[0].PullRequest.Head.Repository.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].PullRequest.Head.Repository.FullName)
|
||||
assert.EqualValues(t, 0, *payloads[0].PullRequest.Additions)
|
||||
assert.EqualValues(t, 0, *payloads[0].PullRequest.ChangedFiles)
|
||||
assert.EqualValues(t, 0, *payloads[0].PullRequest.Deletions)
|
||||
assert.Equal(t, "repo1", payloads[0].PullRequest.Base.Repository.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].PullRequest.Base.Repository.FullName)
|
||||
assert.Equal(t, "repo1", payloads[0].PullRequest.Head.Repository.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].PullRequest.Head.Repository.FullName)
|
||||
assert.Equal(t, 0, *payloads[0].PullRequest.Additions)
|
||||
assert.Equal(t, 0, *payloads[0].PullRequest.ChangedFiles)
|
||||
assert.Equal(t, 0, *payloads[0].PullRequest.Deletions)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -419,14 +419,14 @@ func Test_WebhookPullRequestComment(t *testing.T) {
|
||||
testIssueAddComment(t, session, "/user2/repo1/pulls/"+prID, "pull title2 comment1", "")
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "pull_request_comment", triggeredEvent)
|
||||
assert.Equal(t, "pull_request_comment", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.EqualValues(t, "first pull request", payloads[0].Issue.Title)
|
||||
assert.EqualValues(t, "", payloads[0].Issue.Body)
|
||||
assert.EqualValues(t, "pull title2 comment1", payloads[0].Comment.Body)
|
||||
assert.Equal(t, "repo1", payloads[0].Issue.Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Issue.Repo.FullName)
|
||||
assert.Equal(t, "first pull request", payloads[0].Issue.Title)
|
||||
assert.Empty(t, payloads[0].Issue.Body)
|
||||
assert.Equal(t, "pull title2 comment1", payloads[0].Comment.Body)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -453,12 +453,12 @@ func Test_WebhookWiki(t *testing.T) {
|
||||
testAPICreateWikiPage(t, session, "user2", "repo1", "Test Wiki Page", http.StatusCreated)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "wiki", triggeredEvent)
|
||||
assert.Equal(t, "wiki", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repository.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repository.FullName)
|
||||
assert.EqualValues(t, "Test-Wiki-Page", payloads[0].Page)
|
||||
assert.Equal(t, "repo1", payloads[0].Repository.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repository.FullName)
|
||||
assert.Equal(t, "Test-Wiki-Page", payloads[0].Page)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -485,12 +485,12 @@ func Test_WebhookRepository(t *testing.T) {
|
||||
testAPIOrgCreateRepo(t, session, "org3", "repo_new", http.StatusCreated)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "repository", triggeredEvent)
|
||||
assert.Equal(t, "repository", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.EqualValues(t, "org3", payloads[0].Organization.UserName)
|
||||
assert.EqualValues(t, "repo_new", payloads[0].Repository.Name)
|
||||
assert.EqualValues(t, "org3/repo_new", payloads[0].Repository.FullName)
|
||||
assert.Equal(t, "org3", payloads[0].Organization.UserName)
|
||||
assert.Equal(t, "repo_new", payloads[0].Repository.Name)
|
||||
assert.Equal(t, "org3/repo_new", payloads[0].Repository.FullName)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -521,13 +521,13 @@ func Test_WebhookPackage(t *testing.T) {
|
||||
MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "package", triggeredEvent)
|
||||
assert.Equal(t, "package", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, "created", payloads[0].Action)
|
||||
assert.EqualValues(t, "gitea", payloads[0].Package.Name)
|
||||
assert.EqualValues(t, "generic", payloads[0].Package.Type)
|
||||
assert.EqualValues(t, "org3", payloads[0].Organization.UserName)
|
||||
assert.EqualValues(t, "v1.24.0", payloads[0].Package.Version)
|
||||
assert.Equal(t, "gitea", payloads[0].Package.Name)
|
||||
assert.Equal(t, "generic", payloads[0].Package.Type)
|
||||
assert.Equal(t, "org3", payloads[0].Organization.UserName)
|
||||
assert.Equal(t, "v1.24.0", payloads[0].Package.Version)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -574,13 +574,13 @@ func Test_WebhookStatus(t *testing.T) {
|
||||
})(t)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "status", triggeredEvent)
|
||||
assert.Equal(t, "status", triggeredEvent)
|
||||
assert.Len(t, payloads, 1)
|
||||
assert.EqualValues(t, commitID, payloads[0].Commit.ID)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.EqualValues(t, "testci", payloads[0].Context)
|
||||
assert.EqualValues(t, commitID, payloads[0].SHA)
|
||||
assert.Equal(t, commitID, payloads[0].Commit.ID)
|
||||
assert.Equal(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "testci", payloads[0].Context)
|
||||
assert.Equal(t, commitID, payloads[0].SHA)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ func Test_WebhookStatus_NoWrongTrigger(t *testing.T) {
|
||||
testCreateFile(t, session, "user2", "repo1", "master", "test_webhook_push.md", "# a test file for webhook push")
|
||||
|
||||
// 3. validate the webhook is triggered with right event
|
||||
assert.EqualValues(t, "push", trigger)
|
||||
assert.Equal(t, "push", trigger)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -667,20 +667,20 @@ jobs:
|
||||
assert.NoError(t, err)
|
||||
|
||||
// 3. validate the webhook is triggered
|
||||
assert.EqualValues(t, "workflow_job", triggeredEvent)
|
||||
assert.Equal(t, "workflow_job", triggeredEvent)
|
||||
assert.Len(t, payloads, 2)
|
||||
assert.EqualValues(t, "queued", payloads[0].Action)
|
||||
assert.EqualValues(t, "queued", payloads[0].WorkflowJob.Status)
|
||||
assert.EqualValues(t, []string{"ubuntu-latest"}, payloads[0].WorkflowJob.Labels)
|
||||
assert.EqualValues(t, commitID, payloads[0].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
assert.Equal(t, "queued", payloads[0].Action)
|
||||
assert.Equal(t, "queued", payloads[0].WorkflowJob.Status)
|
||||
assert.Equal(t, []string{"ubuntu-latest"}, payloads[0].WorkflowJob.Labels)
|
||||
assert.Equal(t, commitID, payloads[0].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[0].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[0].Repo.FullName)
|
||||
|
||||
assert.EqualValues(t, "waiting", payloads[1].Action)
|
||||
assert.EqualValues(t, "waiting", payloads[1].WorkflowJob.Status)
|
||||
assert.EqualValues(t, commitID, payloads[1].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[1].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[1].Repo.FullName)
|
||||
assert.Equal(t, "waiting", payloads[1].Action)
|
||||
assert.Equal(t, "waiting", payloads[1].WorkflowJob.Status)
|
||||
assert.Equal(t, commitID, payloads[1].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[1].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[1].Repo.FullName)
|
||||
|
||||
// 4. Execute a single Job
|
||||
task := runner.fetchTask(t)
|
||||
@@ -691,33 +691,33 @@ jobs:
|
||||
runner.execTask(t, task, outcome)
|
||||
|
||||
// 5. validate the webhook is triggered
|
||||
assert.EqualValues(t, "workflow_job", triggeredEvent)
|
||||
assert.Equal(t, "workflow_job", triggeredEvent)
|
||||
assert.Len(t, payloads, 5)
|
||||
assert.EqualValues(t, "in_progress", payloads[2].Action)
|
||||
assert.EqualValues(t, "in_progress", payloads[2].WorkflowJob.Status)
|
||||
assert.EqualValues(t, "mock-runner", payloads[2].WorkflowJob.RunnerName)
|
||||
assert.EqualValues(t, commitID, payloads[2].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[2].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[2].Repo.FullName)
|
||||
assert.Equal(t, "in_progress", payloads[2].Action)
|
||||
assert.Equal(t, "in_progress", payloads[2].WorkflowJob.Status)
|
||||
assert.Equal(t, "mock-runner", payloads[2].WorkflowJob.RunnerName)
|
||||
assert.Equal(t, commitID, payloads[2].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[2].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[2].Repo.FullName)
|
||||
|
||||
assert.EqualValues(t, "completed", payloads[3].Action)
|
||||
assert.EqualValues(t, "completed", payloads[3].WorkflowJob.Status)
|
||||
assert.EqualValues(t, "mock-runner", payloads[3].WorkflowJob.RunnerName)
|
||||
assert.EqualValues(t, "success", payloads[3].WorkflowJob.Conclusion)
|
||||
assert.EqualValues(t, commitID, payloads[3].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[3].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[3].Repo.FullName)
|
||||
assert.Equal(t, "completed", payloads[3].Action)
|
||||
assert.Equal(t, "completed", payloads[3].WorkflowJob.Status)
|
||||
assert.Equal(t, "mock-runner", payloads[3].WorkflowJob.RunnerName)
|
||||
assert.Equal(t, "success", payloads[3].WorkflowJob.Conclusion)
|
||||
assert.Equal(t, commitID, payloads[3].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[3].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[3].Repo.FullName)
|
||||
assert.Contains(t, payloads[3].WorkflowJob.URL, fmt.Sprintf("/actions/runs/%d/jobs/%d", payloads[3].WorkflowJob.RunID, payloads[3].WorkflowJob.ID))
|
||||
assert.Contains(t, payloads[3].WorkflowJob.URL, payloads[3].WorkflowJob.RunURL)
|
||||
assert.Contains(t, payloads[3].WorkflowJob.HTMLURL, fmt.Sprintf("/jobs/%d", 0))
|
||||
assert.Len(t, payloads[3].WorkflowJob.Steps, 1)
|
||||
|
||||
assert.EqualValues(t, "queued", payloads[4].Action)
|
||||
assert.EqualValues(t, "queued", payloads[4].WorkflowJob.Status)
|
||||
assert.EqualValues(t, []string{"ubuntu-latest"}, payloads[4].WorkflowJob.Labels)
|
||||
assert.EqualValues(t, commitID, payloads[4].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[4].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[4].Repo.FullName)
|
||||
assert.Equal(t, "queued", payloads[4].Action)
|
||||
assert.Equal(t, "queued", payloads[4].WorkflowJob.Status)
|
||||
assert.Equal(t, []string{"ubuntu-latest"}, payloads[4].WorkflowJob.Labels)
|
||||
assert.Equal(t, commitID, payloads[4].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[4].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[4].Repo.FullName)
|
||||
|
||||
// 6. Execute a single Job
|
||||
task = runner.fetchTask(t)
|
||||
@@ -728,23 +728,23 @@ jobs:
|
||||
runner.execTask(t, task, outcome)
|
||||
|
||||
// 7. validate the webhook is triggered
|
||||
assert.EqualValues(t, "workflow_job", triggeredEvent)
|
||||
assert.Equal(t, "workflow_job", triggeredEvent)
|
||||
assert.Len(t, payloads, 7)
|
||||
assert.EqualValues(t, "in_progress", payloads[5].Action)
|
||||
assert.EqualValues(t, "in_progress", payloads[5].WorkflowJob.Status)
|
||||
assert.EqualValues(t, "mock-runner", payloads[5].WorkflowJob.RunnerName)
|
||||
assert.Equal(t, "in_progress", payloads[5].Action)
|
||||
assert.Equal(t, "in_progress", payloads[5].WorkflowJob.Status)
|
||||
assert.Equal(t, "mock-runner", payloads[5].WorkflowJob.RunnerName)
|
||||
|
||||
assert.EqualValues(t, commitID, payloads[5].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[5].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[5].Repo.FullName)
|
||||
assert.Equal(t, commitID, payloads[5].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[5].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[5].Repo.FullName)
|
||||
|
||||
assert.EqualValues(t, "completed", payloads[6].Action)
|
||||
assert.EqualValues(t, "completed", payloads[6].WorkflowJob.Status)
|
||||
assert.EqualValues(t, "failure", payloads[6].WorkflowJob.Conclusion)
|
||||
assert.EqualValues(t, "mock-runner", payloads[6].WorkflowJob.RunnerName)
|
||||
assert.EqualValues(t, commitID, payloads[6].WorkflowJob.HeadSha)
|
||||
assert.EqualValues(t, "repo1", payloads[6].Repo.Name)
|
||||
assert.EqualValues(t, "user2/repo1", payloads[6].Repo.FullName)
|
||||
assert.Equal(t, "completed", payloads[6].Action)
|
||||
assert.Equal(t, "completed", payloads[6].WorkflowJob.Status)
|
||||
assert.Equal(t, "failure", payloads[6].WorkflowJob.Conclusion)
|
||||
assert.Equal(t, "mock-runner", payloads[6].WorkflowJob.RunnerName)
|
||||
assert.Equal(t, commitID, payloads[6].WorkflowJob.HeadSha)
|
||||
assert.Equal(t, "repo1", payloads[6].Repo.Name)
|
||||
assert.Equal(t, "user2/repo1", payloads[6].Repo.FullName)
|
||||
assert.Contains(t, payloads[6].WorkflowJob.URL, fmt.Sprintf("/actions/runs/%d/jobs/%d", payloads[6].WorkflowJob.RunID, payloads[6].WorkflowJob.ID))
|
||||
assert.Contains(t, payloads[6].WorkflowJob.URL, payloads[6].WorkflowJob.RunURL)
|
||||
assert.Contains(t, payloads[6].WorkflowJob.HTMLURL, fmt.Sprintf("/jobs/%d", 1))
|
||||
|
@@ -271,11 +271,11 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
|
||||
expectedFileResponse := getExpectedFileResponseForRepofilesCreate(commitID, lastCommit.ID.String())
|
||||
assert.NotNil(t, expectedFileResponse)
|
||||
if expectedFileResponse != nil {
|
||||
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -306,11 +306,11 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
|
||||
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -355,12 +355,12 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
||||
assert.Nil(t, fromEntry) // Should no longer exist here
|
||||
assert.NotNil(t, toEntry) // Should exist here
|
||||
// assert SHA has remained the same but paths use the new file name
|
||||
assert.EqualValues(t, expectedFileResponse.Content.SHA, filesResponse.Files[0].SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Content.Name, filesResponse.Files[0].Name)
|
||||
assert.EqualValues(t, expectedFileResponse.Content.Path, filesResponse.Files[0].Path)
|
||||
assert.EqualValues(t, expectedFileResponse.Content.URL, filesResponse.Files[0].URL)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
assert.Equal(t, expectedFileResponse.Content.SHA, filesResponse.Files[0].SHA)
|
||||
assert.Equal(t, expectedFileResponse.Content.Name, filesResponse.Files[0].Name)
|
||||
assert.Equal(t, expectedFileResponse.Content.Path, filesResponse.Files[0].Path)
|
||||
assert.Equal(t, expectedFileResponse.Content.URL, filesResponse.Files[0].URL)
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
||||
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
||||
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -421,10 +421,10 @@ func testDeleteRepoFiles(t *testing.T, u *url.URL) {
|
||||
expectedFileResponse := getExpectedFileResponseForRepofilesDelete()
|
||||
assert.NotNil(t, filesResponse)
|
||||
assert.Nil(t, filesResponse.Files[0])
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
|
||||
assert.EqualValues(t, expectedFileResponse.Verification, filesResponse.Verification)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
|
||||
assert.Equal(t, expectedFileResponse.Verification, filesResponse.Verification)
|
||||
})
|
||||
|
||||
t.Run("Verify README.md has been deleted", func(t *testing.T) {
|
||||
@@ -463,10 +463,10 @@ func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
||||
expectedFileResponse := getExpectedFileResponseForRepofilesDelete()
|
||||
assert.NotNil(t, filesResponse)
|
||||
assert.Nil(t, filesResponse.Files[0])
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
|
||||
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
|
||||
assert.EqualValues(t, expectedFileResponse.Verification, filesResponse.Verification)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
|
||||
assert.Equal(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
|
||||
assert.Equal(t, expectedFileResponse.Verification, filesResponse.Verification)
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -27,11 +27,11 @@ func Test_RegenerateSession(t *testing.T) {
|
||||
|
||||
sess, err := auth.RegenerateSession(db.DefaultContext, "", key)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, key, sess.Key)
|
||||
assert.Equal(t, key, sess.Key)
|
||||
assert.Empty(t, sess.Data)
|
||||
|
||||
sess, err = auth.ReadSession(db.DefaultContext, key2)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, key2, sess.Key)
|
||||
assert.Equal(t, key2, sess.Key)
|
||||
assert.Empty(t, sess.Data)
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ func testLoginFailed(t *testing.T, username, password, message string) {
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
resultMsg := htmlDoc.doc.Find(".ui.message>p").Text()
|
||||
|
||||
assert.EqualValues(t, message, resultMsg)
|
||||
assert.Equal(t, message, resultMsg)
|
||||
}
|
||||
|
||||
func TestSignin(t *testing.T) {
|
||||
|
@@ -87,6 +87,6 @@ func testGetAvatarRedirect(t *testing.T, user *user_model.User) {
|
||||
t.Run(fmt.Sprintf("getAvatarRedirect_%s", user.Name), func(t *testing.T) {
|
||||
req := NewRequestf(t, "GET", "/%s.png", user.Name)
|
||||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.EqualValues(t, fmt.Sprintf("/avatars/%s", user.Avatar), resp.Header().Get("location"))
|
||||
assert.Equal(t, fmt.Sprintf("/avatars/%s", user.Avatar), resp.Header().Get("location"))
|
||||
})
|
||||
}
|
||||
|
@@ -217,12 +217,12 @@ func TestGetUserRss(t *testing.T) {
|
||||
user34 := "the_34-user.with.all.allowedChars"
|
||||
req := NewRequestf(t, "GET", "/%s.rss", user34)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
if assert.EqualValues(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
|
||||
if assert.Equal(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
|
||||
rssDoc := NewHTMLParser(t, resp.Body).Find("channel")
|
||||
title, _ := rssDoc.ChildrenFiltered("title").Html()
|
||||
assert.EqualValues(t, "Feed of "the_1-user.with.all.allowedChars"", title)
|
||||
assert.Equal(t, "Feed of "the_1-user.with.all.allowedChars"", title)
|
||||
description, _ := rssDoc.ChildrenFiltered("description").Html()
|
||||
assert.EqualValues(t, "<p dir="auto">some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
|
||||
assert.Equal(t, "<p dir="auto">some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
|
||||
}
|
||||
|
||||
req = NewRequestf(t, "GET", "/non-existent-user.rss")
|
||||
@@ -247,11 +247,11 @@ func TestListStopWatches(t *testing.T) {
|
||||
stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID})
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: stopwatch.IssueID})
|
||||
if assert.Len(t, apiWatches, 1) {
|
||||
assert.EqualValues(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
|
||||
assert.EqualValues(t, issue.Index, apiWatches[0].IssueIndex)
|
||||
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Equal(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
|
||||
assert.Equal(t, issue.Index, apiWatches[0].IssueIndex)
|
||||
assert.Equal(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.Equal(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.Equal(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ func assertFileExist(t *testing.T, p string) {
|
||||
func assertFileEqual(t *testing.T, p string, content []byte) {
|
||||
bs, err := os.ReadFile(p)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, content, bs)
|
||||
assert.Equal(t, content, bs)
|
||||
}
|
||||
|
||||
func TestRepoCloneWiki(t *testing.T) {
|
||||
@@ -69,6 +69,6 @@ func Test_RepoWikiPages(t *testing.T) {
|
||||
href, _ := firstAnchor.Attr("href")
|
||||
pagePath := strings.TrimPrefix(href, "/user2/repo1/wiki/")
|
||||
|
||||
assert.EqualValues(t, expectedPagePaths[i], pagePath)
|
||||
assert.Equal(t, expectedPagePaths[i], pagePath)
|
||||
})
|
||||
}
|
||||
|
@@ -32,8 +32,8 @@ func TestXSSUserFullName(t *testing.T) {
|
||||
req = NewRequestf(t, "GET", "/%s", user.Name)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
assert.EqualValues(t, 0, htmlDoc.doc.Find("script.evil").Length())
|
||||
assert.EqualValues(t, fullName,
|
||||
assert.Equal(t, 0, htmlDoc.doc.Find("script.evil").Length())
|
||||
assert.Equal(t, fullName,
|
||||
htmlDoc.doc.Find("div.content").Find(".header.text.center").Text(),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user