mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-03 13:11:05 +00:00
26 lines
723 B
Go
26 lines
723 B
Go
package agent
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeDiscoverySurfaceHost(t *testing.T) {
|
|
cases := []struct {
|
|
surface string
|
|
want string
|
|
}{
|
|
{"example.com", "example.com"},
|
|
{"Example.COM:8443", "example.com"},
|
|
{"example.com./api", "example.com"},
|
|
{"https://example.com:8443/app", "example.com"},
|
|
{"https://[2001:db8::1]:8443/app", "2001:db8::1"},
|
|
{"[2001:db8::1]:8443", "2001:db8::1"},
|
|
{"[2001:db8::1]", "2001:db8::1"},
|
|
{"2001:db8::1", "2001:db8::1"},
|
|
{"10.0.0.5:80/path", "10.0.0.5"},
|
|
{"", ""},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := normalizeDiscoverySurfaceHost(tc.surface); got != tc.want {
|
|
t.Errorf("normalizeDiscoverySurfaceHost(%q) = %q, want %q", tc.surface, got, tc.want)
|
|
}
|
|
}
|
|
}
|