-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrawler_test.go
More file actions
43 lines (37 loc) · 990 Bytes
/
crawler_test.go
File metadata and controls
43 lines (37 loc) · 990 Bytes
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
package main
import (
"testing"
)
var client = TlsConfig()
func TestGetUriSuccess(t* testing.T) {
ret,_ := GetUri(client,"http://www.google.com")
if !ret {
t.Error("GetUri does not return for valid URI")
}
}
func TestGetUriFail(t* testing.T) {
ret,_ := GetUri(client,"www.google.com")
if ret {
t.Error("GetUri returns for invalid URI")
}
}
func TestCrawlerStartFail(t* testing.T) {
c := Crawler{}
defer func() {
if recover() == nil {
t.Error("Crawler starts without required fields")
}
}()
c.Start()
}
func TestCrawlerStop(t* testing.T) {
c := Crawler{Sitemap: make(map[string]*Page),
Deferred: make(map[string]string),
Root: "http://www.tomblomfield.com",
MaxRoutines: 500}
c.Start()
c.Running = false
if len(c.Sem) != 500 {
t.Error("Crawler not using all goroutines required/specified")
}
}