forked from kevadesu/forgejo
Fix linting issues
This commit is contained in:
parent
674689af4a
commit
fe18428806
34 changed files with 64 additions and 69 deletions
|
@ -40,7 +40,7 @@ func TestAPIListStopWatches(t *testing.T) {
|
|||
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.Greater(t, apiWatches[0].Seconds, int64(0))
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -52,15 +53,15 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
remoteAddress := fmt.Sprintf("%s%s/%s", u.String(), url.PathEscape(user.Name), url.PathEscape(mirrorRepo.Name))
|
||||
|
||||
deletePushMirrors := repo_model.DeletePushMirrors
|
||||
deletePushMirrorsError := "deletePushMirrorsError"
|
||||
deletePushMirrorsError := errors.New("deletePushMirrorsError")
|
||||
deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error {
|
||||
return fmt.Errorf(deletePushMirrorsError)
|
||||
return deletePushMirrorsError
|
||||
}
|
||||
|
||||
addPushMirrorRemote := mirror_service.AddPushMirrorRemote
|
||||
addPushMirrorRemoteError := "addPushMirrorRemoteError"
|
||||
addPushMirrorRemoteError := errors.New("addPushMirrorRemoteError")
|
||||
addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error {
|
||||
return fmt.Errorf(addPushMirrorRemoteError)
|
||||
return addPushMirrorRemoteError
|
||||
}
|
||||
|
||||
for _, testCase := range []struct {
|
||||
|
@ -81,7 +82,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
},
|
||||
{
|
||||
name: "fail to add and delete",
|
||||
message: deletePushMirrorsError,
|
||||
message: deletePushMirrorsError.Error(),
|
||||
status: http.StatusInternalServerError,
|
||||
mirrorCount: 1,
|
||||
setup: func() {
|
||||
|
@ -91,7 +92,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
},
|
||||
{
|
||||
name: "fail to add",
|
||||
message: addPushMirrorRemoteError,
|
||||
message: addPushMirrorRemoteError.Error(),
|
||||
status: http.StatusInternalServerError,
|
||||
mirrorCount: 0,
|
||||
setup: func() {
|
||||
|
|
|
@ -266,17 +266,17 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) {
|
|||
createNewReleaseUsingAPI(t, token, owner, repo, "release-tag", "", "Release Tag", "test")
|
||||
|
||||
// delete release
|
||||
req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
|
||||
req := NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNoContent)
|
||||
|
||||
// make sure release is deleted
|
||||
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
|
||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
// delete release tag too
|
||||
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name)).
|
||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNoContent)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestAPIRepoTeams(t *testing.T) {
|
|||
if assert.Len(t, teams, 2) {
|
||||
assert.EqualValues(t, "Owners", teams[0].Name)
|
||||
assert.True(t, teams[0].CanCreateOrgRepo)
|
||||
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units), fmt.Sprintf("%v == %v", unit.AllUnitKeyNames(), teams[0].Units))
|
||||
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units))
|
||||
assert.EqualValues(t, "owner", teams[0].Permission)
|
||||
|
||||
assert.EqualValues(t, "test_team", teams[1].Name)
|
||||
|
|
|
@ -42,7 +42,7 @@ func (doc *HTMLDoc) AssertDropdown(t testing.TB, name string) *goquery.Selection
|
|||
t.Helper()
|
||||
|
||||
dropdownGroup := doc.Find(fmt.Sprintf(".dropdown:has(input[name='%s'])", name))
|
||||
assert.Equal(t, 1, dropdownGroup.Length(), fmt.Sprintf("%s dropdown does not exist", name))
|
||||
assert.Equal(t, 1, dropdownGroup.Length(), "%s dropdown does not exist", name)
|
||||
return dropdownGroup
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ func (doc *HTMLDoc) AssertDropdownHasSelectedOption(t testing.TB, dropdownName,
|
|||
dropdownGroup := doc.AssertDropdown(t, dropdownName)
|
||||
|
||||
selectedValue, _ := dropdownGroup.Find(fmt.Sprintf("input[name='%s']", dropdownName)).Attr("value")
|
||||
assert.Equal(t, expectedValue, selectedValue, fmt.Sprintf("%s dropdown doesn't have expected value selected", dropdownName))
|
||||
assert.Equal(t, expectedValue, selectedValue, "%s dropdown doesn't have expected value selected", dropdownName)
|
||||
|
||||
dropdownValues := dropdownGroup.Find(".menu [data-value]").Map(func(i int, s *goquery.Selection) string {
|
||||
value, _ := s.Attr("data-value")
|
||||
return value
|
||||
})
|
||||
assert.Contains(t, dropdownValues, expectedValue, fmt.Sprintf("%s dropdown doesn't have an option with expected value", dropdownName))
|
||||
assert.Contains(t, dropdownValues, expectedValue, "%s dropdown doesn't have an option with expected value", dropdownName)
|
||||
}
|
||||
|
||||
// Find gets the descendants of each element in the current set of
|
||||
|
|
|
@ -83,7 +83,7 @@ func TestMigrate(t *testing.T) {
|
|||
{svc: structs.ForgejoService},
|
||||
} {
|
||||
// Step 0: verify the repo is available
|
||||
req := NewRequestf(t, "GET", fmt.Sprintf("/%s/%s", ownerName, repoName))
|
||||
req := NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
|
||||
_ = session.MakeRequest(t, req, http.StatusOK)
|
||||
// Step 1: get the Gitea migration form
|
||||
req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc)
|
||||
|
|
|
@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
|
|||
link, exists := htmlDoc.doc.Find(fmt.Sprintf("form.ui.form[action=\"%s\"]", forkURL)).Attr("action")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
_, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", forkOwner.ID)).Attr("data-value")
|
||||
assert.True(t, exists, fmt.Sprintf("Fork owner '%s' is not present in select box", forkOwnerName))
|
||||
assert.True(t, exists, "Fork owner %q is not present in select box", forkOwnerName)
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"uid": fmt.Sprintf("%d", forkOwner.ID),
|
||||
|
|
|
@ -444,7 +444,7 @@ func TestViewRepoDirectory(t *testing.T) {
|
|||
repoSummary := htmlDoc.doc.Find(".repository-summary")
|
||||
|
||||
repoFilesTable := htmlDoc.doc.Find("#repo-files-table")
|
||||
assert.NotZero(t, len(repoFilesTable.Nodes))
|
||||
assert.NotEmpty(t, repoFilesTable.Nodes)
|
||||
|
||||
assert.Zero(t, description.Length())
|
||||
assert.Zero(t, repoTopics.Length())
|
||||
|
|
|
@ -291,7 +291,7 @@ func TestListStopWatches(t *testing.T) {
|
|||
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.Greater(t, apiWatches[0].Seconds, int64(0))
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue