Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use testing/benchmark interface #1993

Merged
merged 1 commit into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/html_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HtmlDoc struct {
doc *goquery.Document
}

func NewHtmlParser(t *testing.T, content []byte) *HtmlDoc {
func NewHtmlParser(t testing.TB, content []byte) *HtmlDoc {
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
assert.NoError(t, err)
return &HtmlDoc{doc: doc}
Expand Down
16 changes: 8 additions & 8 deletions integrations/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func initIntegrationTest() {
routers.GlobalInit()
}

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

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

const userPassword = "password"

func loginUser(t *testing.T, userName string) *TestSession {
func loginUser(t testing.TB, userName string) *TestSession {
return loginUserWithPassword(t, userName, userPassword)
}

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

func NewRequest(t *testing.T, method, urlStr string) *http.Request {
func NewRequest(t testing.TB, method, urlStr string) *http.Request {
return NewRequestWithBody(t, method, urlStr, nil)
}

func NewRequestWithValues(t *testing.T, method, urlStr string, values map[string]string) *http.Request {
func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string]string) *http.Request {
urlValues := url.Values{}
for key, value := range values {
urlValues[key] = []string{value}
}
return NewRequestWithBody(t, method, urlStr, bytes.NewBufferString(urlValues.Encode()))
}

func NewRequestWithJSON(t *testing.T, method, urlStr string, v interface{}) *http.Request {
func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
jsonBytes, err := json.Marshal(v)
assert.NoError(t, err)
return NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
}

func NewRequestWithBody(t *testing.T, method, urlStr string, body io.Reader) *http.Request {
func NewRequestWithBody(t testing.TB, method, urlStr string, body io.Reader) *http.Request {
request, err := http.NewRequest(method, urlStr, body)
assert.NoError(t, err)
request.RequestURI = urlStr
Expand Down