diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-13 00:30:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 16:30:16 +0000 |
commit | c28e29fd94032aa2804b57512115cd9c5fe76398 (patch) | |
tree | 3f04a87f807eb094e003c2c8026a077301edb423 /tests/integration/integration_test.go | |
parent | bcccf4c0d6149e5e7382226a191abd54848f9416 (diff) | |
download | gitea-c28e29fd94032aa2804b57512115cd9c5fe76398.tar.gz gitea-c28e29fd94032aa2804b57512115cd9c5fe76398.zip |
Refactor tests (#26464)
1. Give the global variable clear names
2. Use generic parameter for `onGiteaRun`
Diffstat (limited to 'tests/integration/integration_test.go')
-rw-r--r-- | tests/integration/integration_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index c904d32ffa..76a65e3f03 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -40,7 +40,7 @@ import ( "github.com/xeipuuv/gojsonschema" ) -var c *web.Route +var testWebRoutes *web.Route type NilResponseRecorder struct { httptest.ResponseRecorder @@ -87,7 +87,7 @@ func TestMain(m *testing.M) { defer cancel() tests.InitTest(true) - c = routers.NormalRoutes() + testWebRoutes = routers.NormalRoutes() // integration test settings... if setting.CfgProvider != nil { @@ -374,7 +374,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest. if req.RemoteAddr == "" { req.RemoteAddr = "test-mock:12345" } - c.ServeHTTP(recorder, req) + testWebRoutes.ServeHTTP(recorder, req) if expectedStatus != NoExpectedStatus { if !assert.EqualValues(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) { logUnexpectedResponse(t, recorder) @@ -386,7 +386,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest. func MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedStatus int) *NilResponseRecorder { t.Helper() recorder := NewNilResponseRecorder() - c.ServeHTTP(recorder, req) + testWebRoutes.ServeHTTP(recorder, req) if expectedStatus != NoExpectedStatus { if !assert.EqualValues(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) { @@ -399,7 +399,7 @@ func MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedSta func MakeRequestNilResponseHashSumRecorder(t testing.TB, req *http.Request, expectedStatus int) *NilResponseHashSumRecorder { t.Helper() recorder := NewNilResponseHashSumRecorder() - c.ServeHTTP(recorder, req) + testWebRoutes.ServeHTTP(recorder, req) if expectedStatus != NoExpectedStatus { if !assert.EqualValues(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) { |