|
5 | 5 | package integrations
|
6 | 6 |
|
7 | 7 | import (
|
| 8 | + "context" |
8 | 9 | "encoding/json"
|
9 | 10 | "fmt"
|
10 | 11 | "io/ioutil"
|
11 | 12 | "net/http"
|
12 | 13 | "testing"
|
| 14 | + "time" |
13 | 15 |
|
14 | 16 | "code.gitea.io/gitea/models"
|
15 | 17 | "code.gitea.io/gitea/modules/auth"
|
| 18 | + "code.gitea.io/gitea/modules/queue" |
16 | 19 | api "code.gitea.io/gitea/modules/structs"
|
17 | 20 |
|
18 | 21 | "github.com/stretchr/testify/assert"
|
@@ -225,11 +228,25 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
|
225 | 228 | Do: string(models.MergeStyleMerge),
|
226 | 229 | })
|
227 | 230 |
|
228 |
| - if ctx.ExpectedCode != 0 { |
229 |
| - ctx.Session.MakeRequest(t, req, ctx.ExpectedCode) |
230 |
| - return |
| 231 | + resp := ctx.Session.MakeRequest(t, req, NoExpectedStatus) |
| 232 | + |
| 233 | + if resp.Code == http.StatusMethodNotAllowed { |
| 234 | + err := api.APIError{} |
| 235 | + DecodeJSON(t, resp, &err) |
| 236 | + assert.EqualValues(t, "Please try again later", err.Message) |
| 237 | + queue.GetManager().FlushAll(context.Background(), 5*time.Second) |
| 238 | + resp = ctx.Session.MakeRequest(t, req, NoExpectedStatus) |
| 239 | + } |
| 240 | + |
| 241 | + expected := ctx.ExpectedCode |
| 242 | + if expected == 0 { |
| 243 | + expected = 200 |
| 244 | + } |
| 245 | + |
| 246 | + if !assert.EqualValues(t, expected, resp.Code, |
| 247 | + "Request: %s %s", req.Method, req.URL.String()) { |
| 248 | + logUnexpectedResponse(t, resp) |
231 | 249 | }
|
232 |
| - ctx.Session.MakeRequest(t, req, 200) |
233 | 250 | }
|
234 | 251 | }
|
235 | 252 |
|
|
0 commit comments