package main import "testing" func TestLoginURL(t *testing.T) { for addr, want := range map[string]string{ "127.0.0.1:8080": "http://127.0.0.1:8080/#/login/tok", "0.0.0.0:8080": "http://127.0.0.1:8080/#/login/tok", // a wildcard cannot be opened "[::]:9000": "http://127.0.0.1:9000/#/login/tok", "[::1]:8080": "http://[::1]:8080/#/login/tok", "192.0.2.7:80": "http://192.0.2.7:80/#/login/tok", } { if got := loginURL(addr, "tok"); got != want { t.Errorf("loginURL(%q) = %q, want %q", addr, got, want) } } }