@@ -22,6 +22,10 @@ import (
22
22
"testing"
23
23
)
24
24
25
+ // We use '.' at the end to make sure resolution treats it an inexistent root domain.
26
+ // It must not resolve to any address.
27
+ const invalidDomain = "invaliddomain."
28
+
25
29
func TestGetTwice (t * testing.T ) {
26
30
m := NewIPMap (nil )
27
31
a := m .Get ("example" )
@@ -33,12 +37,12 @@ func TestGetTwice(t *testing.T) {
33
37
34
38
func TestGetInvalid (t * testing.T ) {
35
39
m := NewIPMap (nil )
36
- s := m .Get ("example" )
40
+ s := m .Get (invalidDomain )
37
41
if ! s .Empty () {
38
- t .Error ("Invalid name should result in an empty set" )
42
+ t .Errorf ("Invalid name should result in an empty set, got %v" , s . ips )
39
43
}
40
44
if len (s .GetAll ()) != 0 {
41
- t .Error ("Empty set should be empty" )
45
+ t .Errorf ("Empty set should be empty, got %v" , s . GetAll () )
42
46
}
43
47
}
44
48
@@ -74,7 +78,7 @@ func TestGetIP(t *testing.T) {
74
78
75
79
func TestAddDomain (t * testing.T ) {
76
80
m := NewIPMap (nil )
77
- s := m .Get ("example" )
81
+ s := m .Get (invalidDomain )
78
82
s .Add ("www.google.com" )
79
83
if s .Empty () {
80
84
t .Error ("Google lookup failed" )
@@ -89,7 +93,7 @@ func TestAddDomain(t *testing.T) {
89
93
}
90
94
func TestAddIP (t * testing.T ) {
91
95
m := NewIPMap (nil )
92
- s := m .Get ("example" )
96
+ s := m .Get (invalidDomain )
93
97
s .Add ("192.0.2.1" )
94
98
ips := s .GetAll ()
95
99
if len (ips ) != 1 {
@@ -121,7 +125,7 @@ func TestConfirmed(t *testing.T) {
121
125
122
126
func TestConfirmNew (t * testing.T ) {
123
127
m := NewIPMap (nil )
124
- s := m .Get ("example" )
128
+ s := m .Get (invalidDomain )
125
129
s .Add ("192.0.2.1" )
126
130
// Confirm a new address.
127
131
s .Confirm (net .ParseIP ("192.0.2.2" ))
0 commit comments