From c28e29fd94032aa2804b57512115cd9c5fe76398 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 13 Aug 2023 00:30:16 +0800 Subject: Refactor tests (#26464) 1. Give the global variable clear names 2. Use generic parameter for `onGiteaRun` --- tests/integration/integration_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/integration/integration_test.go') 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()) { -- cgit v1.2.3