mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
23 lines
713 B
Go
23 lines
713 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestLoad_LogDSNOverride(t *testing.T) {
|
|
t.Setenv("EZ_LOG_PG_DSN", "host=log-db user=postgres dbname=logs")
|
|
t.Setenv("EZ_LOG_PARTITIONING", "monthly")
|
|
t.Setenv("EZ_CORS_ALLOW_ORIGINS", "https://a.example.com,https://b.example.com")
|
|
cfg, err := Load()
|
|
if err != nil {
|
|
t.Fatalf("load config: %v", err)
|
|
}
|
|
if cfg.Log.DSN != "host=log-db user=postgres dbname=logs" {
|
|
t.Fatalf("expected log dsn to be set, got %q", cfg.Log.DSN)
|
|
}
|
|
if cfg.Log.Partitioning != "monthly" {
|
|
t.Fatalf("expected log partitioning to be set, got %q", cfg.Log.Partitioning)
|
|
}
|
|
if len(cfg.CORS.AllowOrigins) != 2 {
|
|
t.Fatalf("expected cors allow origins, got %v", cfg.CORS.AllowOrigins)
|
|
}
|
|
}
|