-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscraper_test.go
More file actions
87 lines (84 loc) · 3.34 KB
/
scraper_test.go
File metadata and controls
87 lines (84 loc) · 3.34 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package iconscraper
import (
"testing"
)
func TestSomeSites(t *testing.T) {
config := Config{
SquareOnly: true,
TargetHeight: 128,
MaxConcurrentRequests: 32,
AllowSvg: false,
}
domains := []string{"google.com", "jotpot.uk", "example.com", "gov.uk", "mevitae.com", "microsoft.com", "apple.com", "golang.org", "rust-lang.org", "pkg.go.dev"}
icons := GetIcons(config, domains)
if icon, ok := icons["example.com"]; ok {
t.Error("found icon for example.com", ok, icon)
}
if icon, ok := icons["jotpot.uk"]; !ok || icon.ImageConfig.Height != 144 {
t.Error("didn't find icon for jotpot.uk", ok, icon)
}
if icon, ok := icons["google.com"]; !ok || icon.ImageConfig.Height != 128 {
t.Error("didn't find icon for google.com", ok, icon)
}
if icon, ok := icons["gov.uk"]; !ok || icon.ImageConfig.Height != 152 {
t.Error("didn't find icon for gov.uk", ok, icon)
}
if icon, ok := icons["mevitae.com"]; !ok || icon.ImageConfig.Height != 300 {
t.Error("didn't find icon for mevitae.com", ok, icon)
}
if icon, ok := icons["microsoft.com"]; !ok || icon.ImageConfig.Height != 128 {
t.Error("didn't find icon for microsoft.com", ok, icon)
}
if icon, ok := icons["apple.com"]; !ok || icon.ImageConfig.Height != 64 {
t.Error("didn't find icon for apple.com", ok, icon)
}
if icon, ok := icons["golang.org"]; !ok || icon.ImageConfig.Height != 288 {
t.Error("didn't find icon for golang.org", ok, icon)
}
if icon, ok := icons["rust-lang.org"]; !ok || icon.ImageConfig.Height != 180 {
t.Error("didn't find icon for rust-land.org", ok, icon)
}
if icon, ok := icons["pkg.go.dev"]; !ok || icon.ImageConfig.Height != 32 {
t.Error("didn't find icon for pkg.go.dev", ok, icon)
}
}
func TestSomeSitesWithSVG(t *testing.T) {
config := Config{
SquareOnly: true,
TargetHeight: 32,
MaxConcurrentRequests: 32,
AllowSvg: true,
}
domains := []string{"google.com", "jotpot.uk", "example.com", "gov.uk", "mevitae.com", "microsoft.com", "apple.com", "golang.org", "rust-lang.org", "pkg.go.dev"}
icons := GetIcons(config, domains)
if icon, ok := icons["example.com"]; ok {
t.Error("found icon for example.com", ok, icon)
}
if icon, ok := icons["jotpot.uk"]; !ok || icon.ImageConfig.Height != 32 {
t.Error("didn't find icon for jotpot.uk", ok, icon)
}
if icon, ok := icons["google.com"]; !ok || icon.ImageConfig.Height != 32 {
t.Error("didn't find icon for google.com", ok, icon)
}
if icon, ok := icons["gov.uk"]; !ok || icon.ImageConfig.Height != 48 {
t.Error("didn't find icon for gov.uk", ok, icon)
}
if icon, ok := icons["mevitae.com"]; !ok || icon.ImageConfig.Height != 100 {
t.Error("didn't find icon for mevitae.com", ok, icon)
}
if icon, ok := icons["microsoft.com"]; !ok || icon.ImageConfig.Height != 128 {
t.Error("didn't find icon for microsoft.com", ok, icon)
}
if icon, ok := icons["apple.com"]; !ok || icon.ImageConfig.Height != 64 {
t.Error("didn't find icon for apple.com", ok, icon)
}
if icon, ok := icons["golang.org"]; !ok || icon.Type != svgMimeType {
t.Error("didn't find icon for golang.org", ok, icon)
}
if icon, ok := icons["rust-lang.org"]; !ok || icon.Type != svgMimeType {
t.Error("didn't find icon for rust-lang.org", ok, icon)
}
if icon, ok := icons["pkg.go.dev"]; !ok || icon.ImageConfig.Height != 32 {
t.Error("didn't find icon for pkg.go.dev", ok, icon)
}
}