-
Notifications
You must be signed in to change notification settings - Fork 2
/
ded_test.go
56 lines (53 loc) · 1.4 KB
/
ded_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
package ded
import (
"testing"
)
func TestIsDisposableEmail(t *testing.T) {
tests := []struct {
name string
email string
want bool
wantErr error
}{
{"not disposable email", "eml@google.com", false, nil},
{"disposable email", "eml@mail.wtf", true, nil},
{"ignore spaces", " eml@mail.wtf ", true, nil},
{"case insensitive", "eml@MAIL.wtf", true, nil},
{"malformed email", "eml.com", false, ErrEmailMalformed},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := IsDisposableEmail(tt.email)
if err != tt.wantErr {
t.Fatalf("IsDisposableEmail() error = %v, wantErr %v", err, tt.wantErr)
}
if got != tt.want {
t.Fatalf("IsDisposableEmail() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsDisposableDomain(t *testing.T) {
tests := []struct {
name string
domain string
want bool
wantErr error
}{
{"not disposable domain", "google.com", false, nil},
{"disposable domain", "mail.wtf", true, nil},
{"ignore spaces", " mail.wtf ", true, nil},
{"case insensitive", "MAIL.wtf", true, nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := IsDisposableDomain(tt.domain)
if err != tt.wantErr {
t.Fatalf("TestIsDisposableDomain() error = %v, wantErr %v", err, tt.wantErr)
}
if got != tt.want {
t.Fatalf("TestIsDisposableDomain() = %v, want %v", got, tt.want)
}
})
}
}