-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisposable_test.go
68 lines (60 loc) · 1.52 KB
/
disposable_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
61
62
63
64
65
66
67
68
package disposable_test
import (
"testing"
"github.com/hsson/go-disposable"
)
func TestDisposableDomain(t *testing.T) {
table := map[string]bool{
"0-180.com": true,
"gmail": false,
"hotmail": false,
"19292.monster": true,
"quant2new.pro": true,
}
for domain, isDisposable := range table {
res := disposable.IsDomainDisposable(domain)
if res != isDisposable {
t.Errorf("%s: got %v want %v", domain, res, isDisposable)
}
}
}
func TestDisposableWildcard(t *testing.T) {
table := map[string]bool{
"A.33mail.com": true,
"A.B.C.33mail.com": true,
"33mail.com": true,
"not.disposable.com": false,
}
for domain, isDisposable := range table {
res := disposable.IsDomainWildcard(domain)
if res != isDisposable {
t.Errorf("%s: got %v want %v", domain, res, isDisposable)
}
}
}
func TestDisposableEmail(t *testing.T) {
table := map[string]bool{
"test@gmail.com": false,
"disposable@quant2new.pro": true,
"foo@33mail.com": true,
"33mail.com@some.stuff.33mail.com": true,
"legit@hotmail.com": false,
}
for domain, isDisposable := range table {
res := disposable.IsEmailAddressDisposable(domain)
if res != isDisposable {
t.Errorf("%s: got %v want %v", domain, res, isDisposable)
}
}
}
func TestDisposableEmailShouldNotPanicOnInvalid(t *testing.T) {
cases := []string{
"33mail.com",
" ",
"@ @@ asd@@__",
"",
}
for _, invalid := range cases {
disposable.IsEmailAddressDisposable(invalid)
}
}