-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
31 lines (26 loc) · 848 Bytes
/
main_test.go
File metadata and controls
31 lines (26 loc) · 848 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
package archiveorg
import (
"strings"
"testing"
)
func TestGetLatestURLs(t *testing.T) {
validUrls := []string{"https://golang.org", "https://go.dev"}
archiveUrls, errs := GetLatestURLs(validUrls, 1, false, "")
for _, err := range errs {
if err != nil {
t.Errorf("error getting latest URLs: %v", err)
}
}
for _, archiveUrl := range archiveUrls {
if !strings.HasPrefix(archiveUrl, "http://web.archive.org") {
t.Errorf("unexpected response from archive.org: %v", archiveUrl)
}
}
unarchivedUrls := []string{"https://10qpwo3imdeufnenfuyfgbgbdssd.com"}
archiveUrls, _ = GetLatestURLs(unarchivedUrls, 1, true, "")
for _, archiveUrl := range archiveUrls {
if strings.HasPrefix(archiveUrl, "http://web.archive.org") {
t.Errorf("archive.org unexpectedly has a response for %v: %v", archiveUrl, unarchivedUrls[0])
}
}
}