forked from willwhite/freemail
-
Notifications
You must be signed in to change notification settings - Fork 2
/
freemail_test.go
52 lines (46 loc) · 1.16 KB
/
freemail_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
package freemail
import "testing"
var testDomains = map[string]bool{
"bademail.com": true,
"bad.email.co.uk": true,
}
func TestFind(t *testing.T) {
cases := map[string]bool{
"bademail.com": true,
"goodemail.com": false,
"sub.bademail.com": true,
"bad.email.co.uk": true,
"sub.bad.email.co.uk": true,
"email.co.uk": false,
}
for domain, expected := range cases {
actual := find(domain, testDomains)
if actual != expected {
t.Errorf("For %s, expected %v was %v", domain, expected, actual)
}
}
}
func TestIsFree(t *testing.T) {
if !IsFree("gmail.com") {
t.Errorf("expected 'gmail.com' to be free")
}
if IsFree("google.com") {
t.Errorf("expected 'google.com' not to be free")
}
}
func TestIsDisposable(t *testing.T) {
if !IsDisposable("mailinator.com") {
t.Errorf("expected 'mailinator.com' to be disposable")
}
if IsDisposable("google.com") {
t.Errorf("expected 'google.com' not to be disposable")
}
}
func TestIsSpammy(t *testing.T) {
if !IsSpammy("aribeth.ru") {
t.Errorf("expected 'aribeth.ru' to be spammy")
}
if IsSpammy("google.com") {
t.Errorf("expected 'google.com' not to be disposable")
}
}