ARTEX/agent/discovery_surface_host_test.go
simple-minded 50d033e8d7
test(agent): cover discovery surface host normalization
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 20:40:20 +05:30

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)
}
}
}