(t *testing.T)
| 165 | } |
| 166 | |
| 167 | func TestPolicyDefaultsAndClamps(t *testing.T) { |
| 168 | t.Run("defaults for empty config", func(t *testing.T) { |
| 169 | var cfg ProjectConfig |
| 170 | if got := cfg.ModeOrDefault(); got != "auto" { |
| 171 | t.Fatalf("ModeOrDefault() = %q, want auto", got) |
| 172 | } |
| 173 | if got := cfg.SessionStartOutputBytes(); got != limits.MaxStructureOutputBytes { |
| 174 | t.Fatalf("SessionStartOutputBytes() = %d, want %d", got, limits.MaxStructureOutputBytes) |
| 175 | } |
| 176 | if got := cfg.DiffOutputBytes(); got != limits.MaxDiffOutputBytes { |
| 177 | t.Fatalf("DiffOutputBytes() = %d, want %d", got, limits.MaxDiffOutputBytes) |
| 178 | } |
| 179 | if got := cfg.HubDisplayLimit(); got != 10 { |
| 180 | t.Fatalf("HubDisplayLimit() = %d, want 10", got) |
| 181 | } |
| 182 | if got := cfg.RoutingStrategyOrDefault(); got != "keyword" { |
| 183 | t.Fatalf("RoutingStrategyOrDefault() = %q, want keyword", got) |
| 184 | } |
| 185 | if got := cfg.RoutingTopKOrDefault(); got != 3 { |
| 186 | t.Fatalf("RoutingTopKOrDefault() = %d, want 3", got) |
| 187 | } |
| 188 | }) |
| 189 | |
| 190 | t.Run("clamps unsafe values", func(t *testing.T) { |
| 191 | cfg := ProjectConfig{ |
| 192 | Mode: "invalid", |
| 193 | Budgets: HookBudgets{ |
| 194 | SessionStartBytes: limits.MaxContextOutputBytes * 5, |
| 195 | DiffBytes: limits.MaxContextOutputBytes * 4, |
| 196 | MaxHubs: 500, |
| 197 | }, |
| 198 | Routing: RoutingConfig{ |
| 199 | Retrieval: RetrievalConfig{ |
| 200 | Strategy: "semantic", |
| 201 | TopK: 0, |
| 202 | }, |
| 203 | }, |
| 204 | } |
| 205 | if got := cfg.ModeOrDefault(); got != "auto" { |
| 206 | t.Fatalf("ModeOrDefault() = %q, want auto", got) |
| 207 | } |
| 208 | if got := cfg.SessionStartOutputBytes(); got != limits.MaxContextOutputBytes { |
| 209 | t.Fatalf("SessionStartOutputBytes() = %d, want %d", got, limits.MaxContextOutputBytes) |
| 210 | } |
| 211 | if got := cfg.DiffOutputBytes(); got != limits.MaxContextOutputBytes { |
| 212 | t.Fatalf("DiffOutputBytes() = %d, want %d", got, limits.MaxContextOutputBytes) |
| 213 | } |
| 214 | if got := cfg.HubDisplayLimit(); got != 100 { |
| 215 | t.Fatalf("HubDisplayLimit() = %d, want 100", got) |
| 216 | } |
| 217 | if got := cfg.RoutingStrategyOrDefault(); got != "keyword" { |
| 218 | t.Fatalf("RoutingStrategyOrDefault() = %q, want keyword", got) |
| 219 | } |
| 220 | if got := cfg.RoutingTopKOrDefault(); got != 3 { |
| 221 | t.Fatalf("RoutingTopKOrDefault() = %d, want 3", got) |
| 222 | } |
| 223 | }) |
| 224 | } |
nothing calls this directly
no test coverage detected