diff options
Diffstat (limited to 'tests/integration/api_helper_for_declarative_test.go')
-rw-r--r-- | tests/integration/api_helper_for_declarative_test.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/integration/api_helper_for_declarative_test.go b/tests/integration/api_helper_for_declarative_test.go index 7755b9861a..b30cdfd0fc 100644 --- a/tests/integration/api_helper_for_declarative_test.go +++ b/tests/integration/api_helper_for_declarative_test.go @@ -4,7 +4,6 @@ package integration import ( - "context" "fmt" "net/http" "net/http/httptest" @@ -34,6 +33,10 @@ type APITestContext struct { func NewAPITestContext(t *testing.T, username, reponame string, scope ...auth.AccessTokenScope) APITestContext { session := loginUser(t, username) + if len(scope) == 0 { + // FIXME: legacy logic: no scope means all + scope = []auth.AccessTokenScope{auth.AccessTokenScopeAll} + } token := getTokenForLoggedInUser(t, session, scope...) return APITestContext{ Session: session, @@ -260,7 +263,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64) var req *RequestWrapper var resp *httptest.ResponseRecorder - for i := 0; i < 6; i++ { + for range 6 { req = NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{ MergeMessageField: "doAPIMergePullRequest Merge", Do: string(repo_model.MergeStyleMerge), @@ -273,8 +276,8 @@ 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) - queue.GetManager().FlushAll(context.Background(), 5*time.Second) + assert.Equal(t, "Please try again later", err.Message) + queue.GetManager().FlushAll(t.Context(), 5*time.Second) <-time.After(1 * time.Second) } @@ -283,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) } |