loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Attempt to handle unready PR in tests (#13305)

Signed-off-by: Andrew Thornton <art27@cantab.net>

authored by

zeripath and committed by
GitHub
66dcf108 7974b341

+21 -4
+21 -4
integrations/api_helper_for_declarative_test.go
··· 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 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) 231 239 } 232 - ctx.Session.MakeRequest(t, req, 200) 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) 249 + } 233 250 } 234 251 } 235 252