(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestLoad_ValidConfig(t *testing.T) { |
| 25 | cfgPath := writeTempConfig(t, ` |
| 26 | server: |
| 27 | port: 8080 |
| 28 | backends: |
| 29 | - name: b1 |
| 30 | type: mock |
| 31 | timeout_ms: 100 |
| 32 | cost: { unit: 1, currency: credit } |
| 33 | capabilities: [chat] |
| 34 | tenants: |
| 35 | - id: t1 |
| 36 | class: premium |
| 37 | priority: high |
| 38 | routing: |
| 39 | default_backend: b1 |
| 40 | reliability: |
| 41 | fallback_enabled: true |
| 42 | fallback_rules: [] |
| 43 | `) |
| 44 | |
| 45 | cfg, err := Load(cfgPath) |
| 46 | if err != nil { |
| 47 | t.Fatalf("expected config to load, got error: %v", err) |
| 48 | } |
| 49 | if cfg.Routing.DefaultBackend != "b1" { |
| 50 | t.Fatalf("unexpected default backend: %s", cfg.Routing.DefaultBackend) |
| 51 | } |
| 52 | if cfg.Telemetry.Exporter != "log" { |
| 53 | t.Fatalf("expected default telemetry exporter log, got %s", cfg.Telemetry.Exporter) |
| 54 | } |
| 55 | if cfg.Server.HealthCacheTTLMS != 2000 { |
| 56 | t.Fatalf("expected default health_cache_ttl_ms 2000, got %d", cfg.Server.HealthCacheTTLMS) |
| 57 | } |
| 58 | if cfg.Server.HealthCheckPerMS != 1500 { |
| 59 | t.Fatalf("expected default health_check_per_backend_ms 1500, got %d", cfg.Server.HealthCheckPerMS) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestLoad_DuplicateBackendName(t *testing.T) { |
| 64 | cfgPath := writeTempConfig(t, ` |
nothing calls this directly
no test coverage detected