forked from benjaminestes/robots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_test.go
32 lines (29 loc) · 839 Bytes
/
types_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
package robots
import "testing"
func TestRobotsPath(t *testing.T) {
var tests = []struct {
input string
want string
}{
{"", "/"},
{"?q=123", "/?q=123"},
{"/page.html", "/page.html"},
{"/page.html#fragment", "/page.html"},
{"/page.html?q=123", "/page.html?q=123"},
{"/page.html?q=123#fragment", "/page.html?q=123"},
{"http://www.example.com/page.html", "/page.html"},
{"http://www.example.com/page.html#fragment", "/page.html"},
{"http://www.example.com/page.html?q=123", "/page.html?q=123"},
{"http://www.example.com/page.html?q=123#fragment", "/page.html?q=123"},
}
for _, test := range tests {
got, ok := robotsPath(test.input)
if !ok {
t.Errorf("couldn't parse %q", test.input)
}
if got != test.want {
t.Errorf("crawlable part of %q is %q, got %q",
test.input, test.want, got)
}
}
}