Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vearne committed Nov 6, 2020
1 parent 4cde13c commit 97c2717
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions primitive/nsresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,21 @@ func TesHttpReslverWithSnapshotFileOnce(t *testing.T) {
So(Diff(addrs1, srvs), ShouldBeFalse)
})
}

func TestDNSResolver(t *testing.T) {
Convey("Test UpdateNameServerAddress Use DNS", t, func() {
srvs := []string{
"examples.com:9876",
}

hosts, _ := net.LookupHost("examples.com")
expectedHosts := make([]string, 0)
for _, host:=range hosts{
expectedHosts = append(expectedHosts, host + ":9876")
}
resolver := NewDNSResolver(srvs)
addrs := resolver.Resolve()

So(Diff(expectedHosts, addrs), ShouldBeFalse)
})
}

0 comments on commit 97c2717

Please sign in to comment.