aboutsummaryrefslogtreecommitdiff
path: root/archive_test.go
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2021-12-07 11:07:13 -0700
committerJordan <me@jordan.im>2021-12-07 11:07:13 -0700
commite4e052cf2709835217a748db7674bb6b45d0a8cf (patch)
treee82c5886b04a532c155f4225ab167b40c6b72380 /archive_test.go
parent1bb7d04b6f090044a31638bd2adbeac004567c4b (diff)
downloadkeep-e4e052cf2709835217a748db7674bb6b45d0a8cf.tar.gz
keep-e4e052cf2709835217a748db7674bb6b45d0a8cf.zip
archive, keep: host -> regexp ignore list
Diffstat (limited to 'archive_test.go')
-rw-r--r--archive_test.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/archive_test.go b/archive_test.go
index 096b628..7e7d4ff 100644
--- a/archive_test.go
+++ b/archive_test.go
@@ -9,7 +9,7 @@ func TestIsArchived(t *testing.T) {
url := "http://example.com/"
archived, status := isArchived(url)
- if archived != true || status != 200 {
+ if !archived || status != 200 {
t.Errorf("Received %t, %d; want %t, %d", archived, status, true, 200)
}
}
@@ -18,11 +18,31 @@ func TestIsNotArchived(t *testing.T) {
url := "http://invalidurl.local/"
archived, _ := isArchived(url)
- if archived == true {
+ 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)
+ }
+}
+
func TestArchive200(t *testing.T) {
url := "http://example.com/"