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"
)
func TestIsArchived(t *testing.T) {
url := "http://example.com/"
archived, status := isArchived(url)
if !archived || status != 200 {
t.Errorf("Received %t, %d; want %t, %d", archived, status, true, 200)
}
}
func TestIsNotArchived(t *testing.T) {
url := "http://invalidurl.local/"
archived, _ := isArchived(url)
if archived {
t.Errorf("Received %t; want %t", archived, false)
}
}
func TestIsIgnored(t *testing.T) {
ignoreRegex := []string{`^https?://([^/]*\.)?example\.[^/]+/`}
url := "https://example.com/path"
ignored := isIgnored(ignoreRegex, url)
if !ignored {
t.Errorf("Received %t; want %t", ignored, true)
}
}
func TestIsNotIgnored(t *testing.T) {
ignoreRegex := []string{`^https?://([^/]*\.)?example\.[^/]+/`}
url := "https://google.com/path"
ignored := isIgnored(ignoreRegex, url)
if ignored {
t.Errorf("Received %t; want %t", ignored, false)
}
}
|