config_test.go
⎇
Raw
1package config
2
3import "testing"
4
5func TestPublicOriginIsCanonical(t *testing.T) {
6 for base, want := range map[string]string{
7 "HTTPS://Forge.Example.COM:443/": "https://forge.example.com",
8 "http://Forge.example.com:80": "http://forge.example.com",
9 "http://localhost:3000": "http://localhost:3000",
10 "https://[::1]:443": "https://[::1]",
11 "https://forge.example.com:8443": "https://forge.example.com:8443",
12 } {
13 t.Setenv("BASE_URL", base)
14 c, err := Load()
15 if err != nil {
16 t.Fatal(err)
17 }
18 if c.PublicOrigin != want {
19 t.Errorf("BASE_URL %q: PublicOrigin = %q, want %q", base, c.PublicOrigin, want)
20 }
21 }
22}
23