Update the FriendlyHost tests for svchost.Hostname

This no longer allows normalization of punycode hostnames. This
shouldn't be a problem, as they were not valid in the first place.
This commit is contained in:
James Bardin 2017-11-20 16:11:39 -05:00
parent 1ac5871a09
commit 98d0d15ddc
1 changed files with 3 additions and 7 deletions

View File

@ -59,7 +59,7 @@ func TestFriendlyHost(t *testing.T) {
source: "xn--s-fka0wmm0zea7g8b.xn--o-8ta85a3b1dwcda1k.io", source: "xn--s-fka0wmm0zea7g8b.xn--o-8ta85a3b1dwcda1k.io",
wantHost: "xn--s-fka0wmm0zea7g8b.xn--o-8ta85a3b1dwcda1k.io", wantHost: "xn--s-fka0wmm0zea7g8b.xn--o-8ta85a3b1dwcda1k.io",
wantDisplay: "ʎɹʇsıƃǝɹ.ɯɹoɟɐɹɹǝʇ.io", wantDisplay: "ʎɹʇsıƃǝɹ.ɯɹoɟɐɹɹǝʇ.io",
wantNorm: "xn--s-fka0wmm0zea7g8b.xn--o-8ta85a3b1dwcda1k.io", wantNorm: InvalidHostString,
wantValid: false, wantValid: false,
}, },
{ {
@ -109,13 +109,9 @@ func TestFriendlyHost(t *testing.T) {
} }
// Also verify that host compares equal with all the variants. // Also verify that host compares equal with all the variants.
if !gotHost.Equal(&FriendlyHost{Raw: tt.wantDisplay}) { if gotHost.Valid() && !gotHost.Equal(&FriendlyHost{Raw: tt.wantDisplay}) {
t.Fatalf("Equal() should be true for %s and %s", tt.wantHost, tt.wantValid) t.Fatalf("Equal() should be true for %s and %s", tt.wantHost, tt.wantDisplay)
} }
if !gotHost.Equal(&FriendlyHost{Raw: tt.wantNorm}) {
t.Fatalf("Equal() should be true for %s and %s", tt.wantHost, tt.wantNorm)
}
}) })
} }
} }