Skip to content

Commit 90f9bb1

Browse files
authored
fix golint error and rename func for suggestion. (#1997)
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 6233e88 commit 90f9bb1

11 files changed

+30
-25
lines changed

integrations/change_default_branch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestChangeDefaultBranch(t *testing.T) {
2525
req := NewRequest(t, "GET", branchesURL)
2626
resp := session.MakeRequest(t, req)
2727
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
28-
doc := NewHtmlParser(t, resp.Body)
28+
doc := NewHTMLParser(t, resp.Body)
2929

3030
req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
3131
"_csrf": doc.GetCSRF(),
@@ -39,7 +39,7 @@ func TestChangeDefaultBranch(t *testing.T) {
3939
req = NewRequest(t, "GET", branchesURL)
4040
resp = session.MakeRequest(t, req)
4141
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
42-
doc = NewHtmlParser(t, resp.Body)
42+
doc = NewHTMLParser(t, resp.Body)
4343

4444
req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
4545
"_csrf": doc.GetInputValueByName("_csrf"),

integrations/delete_user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestDeleteUser(t *testing.T) {
2222
resp := session.MakeRequest(t, req)
2323
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2424

25-
doc := NewHtmlParser(t, resp.Body)
25+
doc := NewHTMLParser(t, resp.Body)
2626
req = NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{
2727
"_csrf": doc.GetCSRF(),
2828
})

integrations/editor_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestCreateFile(t *testing.T) {
2222
resp := session.MakeRequest(t, req)
2323
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2424

25-
doc := NewHtmlParser(t, resp.Body)
25+
doc := NewHTMLParser(t, resp.Body)
2626
lastCommit := doc.GetInputValueByName("last_commit")
2727
assert.NotEmpty(t, lastCommit)
2828

@@ -49,7 +49,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
4949
resp := session.MakeRequest(t, req)
5050
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
5151

52-
doc := NewHtmlParser(t, resp.Body)
52+
doc := NewHTMLParser(t, resp.Body)
5353

5454
// Change master branch to protected
5555
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches?action=protected_branch", map[string]string{
@@ -70,7 +70,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
7070
resp = session.MakeRequest(t, req)
7171
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
7272

73-
doc = NewHtmlParser(t, resp.Body)
73+
doc = NewHTMLParser(t, resp.Body)
7474
lastCommit := doc.GetInputValueByName("last_commit")
7575
assert.NotEmpty(t, lastCommit)
7676

@@ -99,7 +99,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
9999
resp := session.MakeRequest(t, req)
100100
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
101101

102-
htmlDoc := NewHtmlParser(t, resp.Body)
102+
htmlDoc := NewHTMLParser(t, resp.Body)
103103
lastCommit := htmlDoc.GetInputValueByName("last_commit")
104104
assert.NotEmpty(t, lastCommit)
105105

integrations/html_helper.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ import (
1212
"github.com/stretchr/testify/assert"
1313
)
1414

15-
type HtmlDoc struct {
15+
// HTMLDoc struct
16+
type HTMLDoc struct {
1617
doc *goquery.Document
1718
}
1819

19-
func NewHtmlParser(t testing.TB, content []byte) *HtmlDoc {
20+
// NewHTMLParser parse html file
21+
func NewHTMLParser(t testing.TB, content []byte) *HTMLDoc {
2022
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
2123
assert.NoError(t, err)
22-
return &HtmlDoc{doc: doc}
24+
return &HTMLDoc{doc: doc}
2325
}
2426

25-
func (doc *HtmlDoc) GetInputValueById(id string) string {
27+
// GetInputValueByID for get input value by id
28+
func (doc *HTMLDoc) GetInputValueByID(id string) string {
2629
text, _ := doc.doc.Find("#" + id).Attr("value")
2730
return text
2831
}
2932

30-
func (doc *HtmlDoc) GetInputValueByName(name string) string {
33+
// GetInputValueByName for get input value by name
34+
func (doc *HTMLDoc) GetInputValueByName(name string) string {
3135
text, _ := doc.doc.Find("input[name=\"" + name + "\"]").Attr("value")
3236
return text
3337
}
3438

35-
func (doc *HtmlDoc) GetCSRF() string {
39+
// GetCSRF for get CSRC token value from input
40+
func (doc *HTMLDoc) GetCSRF() string {
3641
return doc.GetInputValueByName("_csrf")
3742
}

integrations/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
167167
resp := MakeRequest(req)
168168
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
169169

170-
doc := NewHtmlParser(t, resp.Body)
170+
doc := NewHTMLParser(t, resp.Body)
171171
req = NewRequestWithValues(t, "POST", "/user/login", map[string]string{
172172
"_csrf": doc.GetCSRF(),
173173
"user_name": userName,

integrations/issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/stretchr/testify/assert"
1818
)
1919

20-
func getIssuesSelection(htmlDoc *HtmlDoc) *goquery.Selection {
20+
func getIssuesSelection(htmlDoc *HTMLDoc) *goquery.Selection {
2121
return htmlDoc.doc.Find(".issue.list").Find("li").Find(".title")
2222
}
2323

@@ -50,7 +50,7 @@ func TestNoLoginViewIssuesSortByType(t *testing.T) {
5050
resp := session.MakeRequest(t, req)
5151
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
5252

53-
htmlDoc := NewHtmlParser(t, resp.Body)
53+
htmlDoc := NewHTMLParser(t, resp.Body)
5454
issuesSelection := getIssuesSelection(htmlDoc)
5555
expectedNumIssues := models.GetCount(t,
5656
&models.Issue{RepoID: repo.ID, PosterID: user.ID},

integrations/pull_compare_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestPullCompare(t *testing.T) {
1818
req := NewRequest(t, "GET", "/user2/repo1/pulls")
1919
resp := session.MakeRequest(t, req)
2020
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
21-
htmlDoc := NewHtmlParser(t, resp.Body)
21+
htmlDoc := NewHTMLParser(t, resp.Body)
2222
link, exists := htmlDoc.doc.Find(".navbar").Find(".ui.green.button").Attr("href")
2323
assert.True(t, exists, "The template has changed")
2424

integrations/pull_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
1818
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
1919

2020
// Click the little green button to create a pull
21-
htmlDoc := NewHtmlParser(t, resp.Body)
21+
htmlDoc := NewHTMLParser(t, resp.Body)
2222
link, exists := htmlDoc.doc.Find("button.ui.green.small.button").Parent().Attr("href")
2323
assert.True(t, exists, "The template has changed")
2424

@@ -27,7 +27,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
2727
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2828

2929
// Submit the form for creating the pull
30-
htmlDoc = NewHtmlParser(t, resp.Body)
30+
htmlDoc = NewHTMLParser(t, resp.Body)
3131
link, exists = htmlDoc.doc.Find("form.ui.form").Attr("action")
3232
assert.True(t, exists, "The template has changed")
3333
req = NewRequestWithValues(t, "POST", link, map[string]string{

integrations/pull_merge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
1919
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2020

2121
// Click the little green button to craete a pull
22-
htmlDoc := NewHtmlParser(t, resp.Body)
22+
htmlDoc := NewHTMLParser(t, resp.Body)
2323
link, exists := htmlDoc.doc.Find("form.ui.form>button.ui.green.button").Parent().Attr("action")
2424
assert.True(t, exists, "The template has changed")
2525
req = NewRequestWithValues(t, "POST", link, map[string]string{

integrations/repo_commits_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestRepoCommits(t *testing.T) {
2424
resp := session.MakeRequest(t, req)
2525
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2626

27-
doc := NewHtmlParser(t, resp.Body)
27+
doc := NewHTMLParser(t, resp.Body)
2828
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
2929
assert.True(t, exists)
3030
assert.NotEmpty(t, commitURL)
@@ -40,7 +40,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
4040
resp := session.MakeRequest(t, req)
4141
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
4242

43-
doc := NewHtmlParser(t, resp.Body)
43+
doc := NewHTMLParser(t, resp.Body)
4444
// Get first commit URL
4545
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
4646
assert.True(t, exists)
@@ -64,7 +64,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
6464
resp = session.MakeRequest(t, req)
6565
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
6666

67-
doc = NewHtmlParser(t, resp.Body)
67+
doc = NewHTMLParser(t, resp.Body)
6868
// Check if commit status is displayed in message column
6969
sel := doc.doc.Find("#commits-table tbody tr td.message i.commit-status")
7070
assert.Equal(t, sel.Length(), 1)

integrations/repo_fork_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
2323
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
2424

2525
// Step2: click the fork button
26-
htmlDoc := NewHtmlParser(t, resp.Body)
26+
htmlDoc := NewHTMLParser(t, resp.Body)
2727
link, exists := htmlDoc.doc.Find("a.ui.button[href^=\"/repo/fork/\"]").Attr("href")
2828
assert.True(t, exists, "The template has changed")
2929
req = NewRequest(t, "GET", link)
3030
resp = session.MakeRequest(t, req)
3131
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
3232

3333
// Step3: fill the form of the forking
34-
htmlDoc = NewHtmlParser(t, resp.Body)
34+
htmlDoc = NewHTMLParser(t, resp.Body)
3535
link, exists = htmlDoc.doc.Find("form.ui.form[action^=\"/repo/fork/\"]").Attr("action")
3636
assert.True(t, exists, "The template has changed")
3737
req = NewRequestWithValues(t, "POST", link, map[string]string{

0 commit comments

Comments
 (0)