Allow unit test to pass on machines without ipv6

k3s-v1.14.4
Jordan Liggitt 2019-06-28 10:39:28 -07:00 committed by Nikhita Raghunath
parent d5f2096f1a
commit a50985cbb0
1 changed files with 3 additions and 1 deletions

View File

@ -59,7 +59,9 @@ func TestLoopbackHostPort(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if ip := net.ParseIP(host); ip == nil || !ip.IsLoopback() || ip.To4() != nil { if host == "localhost" {
// can happen on machines without IPv6
} else if ip := net.ParseIP(host); ip == nil || !ip.IsLoopback() || ip.To4() != nil {
t.Fatalf("expected IPv6 host to be loopback, got %q", host) t.Fatalf("expected IPv6 host to be loopback, got %q", host)
} }