-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecked_url_test.go
38 lines (35 loc) · 1.23 KB
/
checked_url_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
33
34
35
36
37
38
package dyatl
import (
"testing"
)
func TestHostAvailable(t *testing.T) {
for url, ok := range map[string]bool{
"https://t.me/joinchat/23948092384098230948230": true,
"https://example.com:1443/sentry/": true,
"https://tewyy24rywe08hwqyef.me": false,
} {
if NewCheckedURL(url).HostAvailable() != ok {
t.Error("fail: available:", url, "!=", ok)
}
}
}
func TestLooksCorrect(t *testing.T) {
for url, ok := range map[string]bool{
"https://t.me/joinchat/siodfusoiudfoisaudfoiu": true,
"https://example.com:1443/sentry/": true,
"https://tewyy24rywe08hwqyef.me": true,
"http://123.ru": true,
"http://123.ru.": true,
"123.ru": false,
"http://sdfsdf": false,
"http://sdfsdf.sdjfajsdklfjalk": false,
"http://sdfsdf.sdjfajsdklfjalk.aero": true,
"HTTPS://ya.ru": true,
".com": false,
"http://.com": false,
} {
if NewCheckedURL(url).LooksCorrect() != ok {
t.Error("fail: looks correct:", url, "!=", ok)
}
}
}