Files
platform/conv/country_test.go
2026-07-20 00:15:42 +02:00

30 lines
679 B
Go

package conv
import "testing"
func TestCountryFromHost(t *testing.T) {
tests := []struct {
host string
want string
}{
{"shop-no.example.com", "no"},
{"SHOP-NO.EXAMPLE.COM", "no"},
{"shop-se.example.com", "se"},
{"shop-se", "se"},
{"shop-no", "no"},
{"example.com", "se"},
{"", "se"},
{"localhost", "se"},
{"https://shop-no.example.com/page", "no"},
{"https://shop-se.example.com", "se"},
{"-no-", "no"},
{"nose.example.com", "se"}, // no "-no" substring — "nose" has no hyphen
}
for _, tt := range tests {
got := CountryFromHost(tt.host)
if got != tt.want {
t.Errorf("CountryFromHost(%q) = %q, want %q", tt.host, got, tt.want)
}
}
}