Skip to content

Commit 6233e88

Browse files
sapklunny
authored andcommitted
Use testing benchmark interface (#1993)
1 parent d757089 commit 6233e88

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

integrations/html_helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type HtmlDoc struct {
1616
doc *goquery.Document
1717
}
1818

19-
func NewHtmlParser(t *testing.T, content []byte) *HtmlDoc {
19+
func NewHtmlParser(t testing.TB, content []byte) *HtmlDoc {
2020
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
2121
assert.NoError(t, err)
2222
return &HtmlDoc{doc: doc}

integrations/integration_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func initIntegrationTest() {
116116
routers.GlobalInit()
117117
}
118118

119-
func prepareTestEnv(t *testing.T) {
119+
func prepareTestEnv(t testing.TB) {
120120
assert.NoError(t, models.LoadFixtures())
121121
assert.NoError(t, os.RemoveAll("integrations/gitea-integration"))
122122
assert.NoError(t, com.CopyDir("integrations/gitea-integration-meta", "integrations/gitea-integration"))
@@ -140,7 +140,7 @@ func (s *TestSession) GetCookie(name string) *http.Cookie {
140140
return nil
141141
}
142142

143-
func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse {
143+
func (s *TestSession) MakeRequest(t testing.TB, req *http.Request) *TestResponse {
144144
baseURL, err := url.Parse(setting.AppURL)
145145
assert.NoError(t, err)
146146
for _, c := range s.jar.Cookies(baseURL) {
@@ -158,11 +158,11 @@ func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse
158158

159159
const userPassword = "password"
160160

161-
func loginUser(t *testing.T, userName string) *TestSession {
161+
func loginUser(t testing.TB, userName string) *TestSession {
162162
return loginUserWithPassword(t, userName, userPassword)
163163
}
164164

165-
func loginUserWithPassword(t *testing.T, userName, password string) *TestSession {
165+
func loginUserWithPassword(t testing.TB, userName, password string) *TestSession {
166166
req := NewRequest(t, "GET", "/user/login")
167167
resp := MakeRequest(req)
168168
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -214,25 +214,25 @@ type TestResponse struct {
214214
Headers http.Header
215215
}
216216

217-
func NewRequest(t *testing.T, method, urlStr string) *http.Request {
217+
func NewRequest(t testing.TB, method, urlStr string) *http.Request {
218218
return NewRequestWithBody(t, method, urlStr, nil)
219219
}
220220

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 {
222222
urlValues := url.Values{}
223223
for key, value := range values {
224224
urlValues[key] = []string{value}
225225
}
226226
return NewRequestWithBody(t, method, urlStr, bytes.NewBufferString(urlValues.Encode()))
227227
}
228228

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 {
230230
jsonBytes, err := json.Marshal(v)
231231
assert.NoError(t, err)
232232
return NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
233233
}
234234

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 {
236236
request, err := http.NewRequest(method, urlStr, body)
237237
assert.NoError(t, err)
238238
request.RequestURI = urlStr

0 commit comments

Comments
 (0)