summaryrefslogtreecommitdiffstats
path: root/integrations/html_helper.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-17 00:49:45 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-17 12:49:45 +0800
commitce9b86082c4824917023b1bb480648d0cc56dd04 (patch)
treeba28673c955d009492557f54953857165e2f8da8 /integrations/html_helper.go
parenta3868ef5367315f52334b81819a412cad820f5eb (diff)
downloadgitea-ce9b86082c4824917023b1bb480648d0cc56dd04.tar.gz
gitea-ce9b86082c4824917023b1bb480648d0cc56dd04.zip
Consolidate boilerplate in integration tests (#1979)
Diffstat (limited to 'integrations/html_helper.go')
-rw-r--r--integrations/html_helper.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/integrations/html_helper.go b/integrations/html_helper.go
index 63f7340c5c..3bddd2930d 100644
--- a/integrations/html_helper.go
+++ b/integrations/html_helper.go
@@ -6,21 +6,20 @@ package integrations
import (
"bytes"
+ "testing"
"github.com/PuerkitoBio/goquery"
+ "github.com/stretchr/testify/assert"
)
type HtmlDoc struct {
doc *goquery.Document
}
-func NewHtmlParser(content []byte) (*HtmlDoc, error) {
+func NewHtmlParser(t *testing.T, content []byte) *HtmlDoc {
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
- if err != nil {
- return nil, err
- }
-
- return &HtmlDoc{doc: doc}, nil
+ assert.NoError(t, err)
+ return &HtmlDoc{doc: doc}
}
func (doc *HtmlDoc) GetInputValueById(id string) string {
@@ -32,3 +31,7 @@ func (doc *HtmlDoc) GetInputValueByName(name string) string {
text, _ := doc.doc.Find("input[name=\"" + name + "\"]").Attr("value")
return text
}
+
+func (doc *HtmlDoc) GetCSRF() string {
+ return doc.GetInputValueByName("_csrf")
+}