package config import "testing" func TestProductionRequiresCoreDependencies(t *testing.T) { t.Setenv("APP_ENV", "production") t.Setenv("DATABASE_URL", "") t.Setenv("REDIS_CRITICAL_URL", "") t.Setenv("GATEWAY_BOOTSTRAP_API_KEY", "short") t.Setenv("UPSTREAM_API_KEY", "") cfg, err := Load() if err != nil { t.Fatalf("unexpected structural configuration error: %v", err) } if err := cfg.ValidateRuntime(); err == nil { t.Fatal("expected production validation error") } } func TestLocalDefaultsAreValid(t *testing.T) { t.Setenv("APP_ENV", "local") t.Setenv("UPSTREAM_BASE_URL", "https://example.com") if _, err := Load(); err != nil { t.Fatalf("unexpected error: %v", err) } } func TestProductionCanDisableBootstrapCompatibility(t *testing.T) { t.Setenv("APP_ENV", "production") t.Setenv("DATABASE_URL", "postgres://gateway:secret@db.example/gateway?sslmode=require") t.Setenv("REDIS_CRITICAL_URL", "rediss://redis.example/0") t.Setenv("GATEWAY_BOOTSTRAP_API_KEY", "") t.Setenv("GATEWAY_BOOTSTRAP_API_KEY_ENABLED", "false") t.Setenv("UPSTREAM_FALLBACK_ENABLED", "false") t.Setenv("CREDENTIAL_MASTER_KEY", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=") t.Setenv("UPSTREAM_BASE_URL", "https://example.com") cfg, err := Load() if err != nil { t.Fatal(err) } if err := cfg.ValidateRuntime(); err != nil { t.Fatalf("disabled bootstrap compatibility should not require a key: %v", err) } }