93cfbd6e2b
Keycloak owns :8080 in the dev stack (docker-compose binds host:8080). Running tenant-registry on the same port made 'make dev' refuse to boot. Bump the default to :8090 across config, Makefile, Dockerfile, .env.example, and README. ADDR env var still overrides if needed. Production is unaffected — each service is in its own Orca container with its own port-namespace. Refs: M5.1 (unblocks portal local dev)
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestLoad_defaults(t *testing.T) {
|
|
t.Setenv("APP_ENV", "")
|
|
t.Setenv("ADDR", "")
|
|
t.Setenv("KEYCLOAK_ISSUER", "")
|
|
t.Setenv("DATABASE_URL", "")
|
|
|
|
cfg, err := Load()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.Env != "dev" {
|
|
t.Errorf("Env = %q, want dev", cfg.Env)
|
|
}
|
|
if cfg.Addr != ":8090" {
|
|
t.Errorf("Addr = %q, want :8090", cfg.Addr)
|
|
}
|
|
if cfg.KeycloakIssuer == "" {
|
|
t.Error("KeycloakIssuer is empty; expected a default")
|
|
}
|
|
if cfg.DatabaseURL != "" {
|
|
t.Errorf("DatabaseURL = %q, want empty default", cfg.DatabaseURL)
|
|
}
|
|
}
|
|
|
|
func TestLoad_overrides(t *testing.T) {
|
|
t.Setenv("APP_ENV", "stage")
|
|
t.Setenv("ADDR", ":9000")
|
|
t.Setenv("KEYCLOAK_ISSUER", "https://auth.example/realms/r")
|
|
t.Setenv("DATABASE_URL", "postgres://x")
|
|
|
|
cfg, err := Load()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.Env != "stage" || cfg.Addr != ":9000" || cfg.KeycloakIssuer != "https://auth.example/realms/r" || cfg.DatabaseURL != "postgres://x" {
|
|
t.Errorf("overrides not applied: %+v", cfg)
|
|
}
|
|
}
|
|
|
|
func TestLoad_invalidEnv(t *testing.T) {
|
|
t.Setenv("APP_ENV", "bogus")
|
|
_, err := Load()
|
|
if err == nil {
|
|
t.Fatal("expected error for invalid APP_ENV")
|
|
}
|
|
}
|