Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit ce82343

Browse files
authored
Fix Intra tests (#119)
1 parent a174da3 commit ce82343

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

intra/doh/ipmap/ipmap_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import (
2222
"testing"
2323
)
2424

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+
2529
func TestGetTwice(t *testing.T) {
2630
m := NewIPMap(nil)
2731
a := m.Get("example")
@@ -33,12 +37,12 @@ func TestGetTwice(t *testing.T) {
3337

3438
func TestGetInvalid(t *testing.T) {
3539
m := NewIPMap(nil)
36-
s := m.Get("example")
40+
s := m.Get(invalidDomain)
3741
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)
3943
}
4044
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())
4246
}
4347
}
4448

@@ -74,7 +78,7 @@ func TestGetIP(t *testing.T) {
7478

7579
func TestAddDomain(t *testing.T) {
7680
m := NewIPMap(nil)
77-
s := m.Get("example")
81+
s := m.Get(invalidDomain)
7882
s.Add("www.google.com")
7983
if s.Empty() {
8084
t.Error("Google lookup failed")
@@ -89,7 +93,7 @@ func TestAddDomain(t *testing.T) {
8993
}
9094
func TestAddIP(t *testing.T) {
9195
m := NewIPMap(nil)
92-
s := m.Get("example")
96+
s := m.Get(invalidDomain)
9397
s.Add("192.0.2.1")
9498
ips := s.GetAll()
9599
if len(ips) != 1 {
@@ -121,7 +125,7 @@ func TestConfirmed(t *testing.T) {
121125

122126
func TestConfirmNew(t *testing.T) {
123127
m := NewIPMap(nil)
124-
s := m.Get("example")
128+
s := m.Get(invalidDomain)
125129
s.Add("192.0.2.1")
126130
// Confirm a new address.
127131
s.Confirm(net.ParseIP("192.0.2.2"))

0 commit comments

Comments
 (0)