-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdomain_test.go
60 lines (53 loc) · 979 Bytes
/
domain_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"encoding/json"
"fmt"
"os"
"testing"
)
func skipCI(t *testing.T) {
if os.Getenv("CI") != "" {
t.Skip("Skipping testing in CI environment")
}
}
func TestValidDomainParse(t *testing.T) {
skipCI(t)
domain, _ := NewDomain("nic.ir")
whois, e := DomainWhois(domain)
whoisJSON, _ := json.Marshal(whois)
fmt.Println(string(whoisJSON))
if e != nil {
t.Error(e)
}
}
func TestNewDomain(t *testing.T) {
domains := []string{
"amazon.co.uk",
"google.com",
"www.google.com",
"بخر.ایران",
"ساب.بخر.ایران",
"sample.gov.ir",
"www.sub.sample.gov.ir",
}
for _, domain := range domains {
_, e := NewDomain(domain)
if e != nil {
t.Error(e)
}
}
invalidDomains := []string{
"AAAAAAAAAAA",
"محمد.آیران",
"😀",
"",
"東京\uFF0EFjp",
"1",
}
for _, domain := range invalidDomains {
_, e := NewDomain(domain)
if e == nil {
t.Errorf("Domain is invalid so we need an error")
}
}
}