Files
navi/internal/geoflag/geoflag_test.go
T

42 lines
1.1 KiB
Go

package geoflag
import "testing"
func TestFromText(t *testing.T) {
cases := []struct {
in, cc string
}{
{"DE-Frankfurt-1", "DE"},
{"[NL] Amsterdam", "NL"},
{"🇺🇸 US West", "US"},
{"Germany Hetzner", "DE"},
{"unknown-node", ""},
// Russian country names.
{"Германия-1", "DE"},
{"Нидерланды Fast", "NL"},
{"Сервер Швейцария", "CH"},
{"США восток", "US"},
{"Великобритания", "GB"},
// City → country hints.
{"Frankfurt-Hetzner", "DE"},
{"Амстердам 2", "NL"},
{"node-helsinki", "FI"},
// Names from live Remnawave subscription (emoji comes first).
{"🇨🇿 Czech Republic Vless", "CZ"},
{"🇳🇴 Norway TR+WS", "NO"},
{"🇩🇪 Germany 3 HY", "DE"},
// Panel-side typos seen in production.
{"Румьиня", "RO"},
{"Румыня-2", "RO"},
}
for _, c := range cases {
cc, emoji := FromText(c.in)
if cc != c.cc {
t.Fatalf("%q: got cc %q want %q", c.in, cc, c.cc)
}
if c.cc != "" && emoji == "" {
t.Fatalf("%q: empty emoji", c.in)
}
}
}