Browse Source

Use testing benchmark interface (#1993)

Antoine GIRARD 2 years ago
parent
commit
6233e88f7f
2 changed files with 9 additions and 9 deletions
  1. 1 1
      integrations/html_helper.go
  2. 8 8
      integrations/integration_test.go

+ 1 - 1
integrations/html_helper.go

@@ -16,7 +16,7 @@ type HtmlDoc struct {
16 16
 	doc *goquery.Document
17 17
 }
18 18
 
19
-func NewHtmlParser(t *testing.T, content []byte) *HtmlDoc {
19
+func NewHtmlParser(t testing.TB, content []byte) *HtmlDoc {
20 20
 	doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
21 21
 	assert.NoError(t, err)
22 22
 	return &HtmlDoc{doc: doc}

+ 8 - 8
integrations/integration_test.go

@@ -116,7 +116,7 @@ func initIntegrationTest() {
116 116
 	routers.GlobalInit()
117 117
 }
118 118
 
119
-func prepareTestEnv(t *testing.T) {
119
+func prepareTestEnv(t testing.TB) {
120 120
 	assert.NoError(t, models.LoadFixtures())
121 121
 	assert.NoError(t, os.RemoveAll("integrations/gitea-integration"))
122 122
 	assert.NoError(t, com.CopyDir("integrations/gitea-integration-meta", "integrations/gitea-integration"))
@@ -140,7 +140,7 @@ func (s *TestSession) GetCookie(name string) *http.Cookie {
140 140
 	return nil
141 141
 }
142 142
 
143
-func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse {
143
+func (s *TestSession) MakeRequest(t testing.TB, req *http.Request) *TestResponse {
144 144
 	baseURL, err := url.Parse(setting.AppURL)
145 145
 	assert.NoError(t, err)
146 146
 	for _, c := range s.jar.Cookies(baseURL) {
@@ -158,11 +158,11 @@ func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse
158 158
 
159 159
 const userPassword = "password"
160 160
 
161
-func loginUser(t *testing.T, userName string) *TestSession {
161
+func loginUser(t testing.TB, userName string) *TestSession {
162 162
 	return loginUserWithPassword(t, userName, userPassword)
163 163
 }
164 164
 
165
-func loginUserWithPassword(t *testing.T, userName, password string) *TestSession {
165
+func loginUserWithPassword(t testing.TB, userName, password string) *TestSession {
166 166
 	req := NewRequest(t, "GET", "/user/login")
167 167
 	resp := MakeRequest(req)
168 168
 	assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -214,11 +214,11 @@ type TestResponse struct {
214 214
 	Headers    http.Header
215 215
 }
216 216
 
217
-func NewRequest(t *testing.T, method, urlStr string) *http.Request {
217
+func NewRequest(t testing.TB, method, urlStr string) *http.Request {
218 218
 	return NewRequestWithBody(t, method, urlStr, nil)
219 219
 }
220 220
 
221
-func NewRequestWithValues(t *testing.T, method, urlStr string, values map[string]string) *http.Request {
221
+func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string]string) *http.Request {
222 222
 	urlValues := url.Values{}
223 223
 	for key, value := range values {
224 224
 		urlValues[key] = []string{value}
@@ -226,13 +226,13 @@ func NewRequestWithValues(t *testing.T, method, urlStr string, values map[string
226 226
 	return NewRequestWithBody(t, method, urlStr, bytes.NewBufferString(urlValues.Encode()))
227 227
 }
228 228
 
229
-func NewRequestWithJSON(t *testing.T, method, urlStr string, v interface{}) *http.Request {
229
+func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
230 230
 	jsonBytes, err := json.Marshal(v)
231 231
 	assert.NoError(t, err)
232 232
 	return NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
233 233
 }
234 234
 
235
-func NewRequestWithBody(t *testing.T, method, urlStr string, body io.Reader) *http.Request {
235
+func NewRequestWithBody(t testing.TB, method, urlStr string, body io.Reader) *http.Request {
236 236
 	request, err := http.NewRequest(method, urlStr, body)
237 237
 	assert.NoError(t, err)
238 238
 	request.RequestURI = urlStr