-
Notifications
You must be signed in to change notification settings - Fork 3
/
mxresolve_test.go
43 lines (37 loc) · 1.07 KB
/
mxresolve_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
//
// Do very crude tests of ValidDomain().
//
package main
import (
"testing"
)
func TestBasicResults(t *testing.T) {
// Has MX entry
a, err := ValidDomain("gmail.com")
if a != dnsGood || err != nil {
t.Fatalf("gmail.com bad: valid %v / %v\n", a, err)
}
// Has A record but no MX (so far, this is crude)
a, err = ValidDomain("www.google.com")
if a != dnsGood || err != nil {
t.Fatalf("www.google.com: valid %v / %v\n", a, err)
}
// Has a null MX. Yeah, this is not a great test either.
// Really we need a synthetic resolver of our own with test
// data, but that's too much work.
a, err = ValidDomain("yahoo.net")
if a != dnsBad || err == nil {
t.Fatalf("yahoo.net: valid %v / %v\n", a, err)
}
// This either. fbi.org has a MX localhost, at least as of
// 2017-05-21 and some time before.
a, err = ValidDomain("fbi.org")
if a != dnsBad || err == nil {
t.Fatalf("fbi.org: valid %v / %v\n", a, err)
}
// No such thing.
a, err = ValidDomain("nosuchdomain.fred")
if a != dnsBad || err == nil {
t.Fatalf("nosuchdomain.fred: valid %v / %v\n", a, err)
}
}