-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_test.go
60 lines (54 loc) · 899 Bytes
/
parse_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package kiteroot
import (
"net/http"
"strings"
"sync"
"testing"
)
func TestParse(t *testing.T) {
html := `
<html>
<head>
<title> KiteRoot </title>
<meta name="user" content="phynalle"/>
<meta name="profile" content="nothing"/>
</head>
<body>
omg
</body>
</html>
`
r := strings.NewReader(html)
_, err := Parse(r)
if err != nil {
t.Fatal(err)
}
}
func TestParseWebPages(t *testing.T) {
list := []string{
"http://golang.org",
"http://google.com",
"http://facebook.com",
"http://apple.com",
"http://github.com",
}
var wg sync.WaitGroup
wg.Add(len(list))
for _, url := range list {
go func(url string) {
resp, err := http.Get(url)
if err != nil {
t.Skipf("[%s] %s", url, err)
wg.Done()
return
}
defer resp.Body.Close()
_, err = Parse(resp.Body)
if err != nil {
t.Errorf("[%s] %s", url, err)
}
wg.Done()
}(url)
}
wg.Wait()
}