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

Consolidate boilerplate in integration tests #1979

Merged
merged 1 commit into from
Jun 17, 2017

Conversation

ethantkoenig
Copy link
Member

Move error-checking and other shared boilerplate to helper functions; makes tests less verbose.

@andreynering
Copy link
Contributor

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jun 15, 2017
@pgaskin
Copy link
Contributor

pgaskin commented Jun 15, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 15, 2017
)
doc := NewHtmlParser(t, resp.Body)
req = NewRequestWithValues(t, "POST", "/user/login", map[string]string{
"_csrf": doc.GetInputValueByName("_csrf"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to GetCSRF

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@@ -155,21 +156,19 @@ func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse
return resp
}

func loginUser(t *testing.T, userName, password string) *TestSession {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think we should do that. How should we test user login with different password?

Copy link
Member Author

@ethantkoenig ethantkoenig Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about having two functions?

func loginUserDefaultPassword(...) {
	loginUser(..., "password")
}

func loginUser(...) {
	// what we originally had
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny Done

@appleboy
Copy link
Member

@ethantkoenig Could you rebase the master? something wrong with drone sig file.

@appleboy appleboy added this to the 1.2.0 milestone Jun 16, 2017
@ethantkoenig
Copy link
Member Author

@appleboy Rebased

@lafriks
Copy link
Member

lafriks commented Jun 16, 2017

LGTM

@lunny lunny merged commit ce9b860 into go-gitea:master Jun 17, 2017
@ethantkoenig ethantkoenig deleted the refactor/integration_test branch June 17, 2017 15:54
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants