(t *testing.T)
| 309 | } |
| 310 | |
| 311 | func TestNewRuntimeValidation(t *testing.T) { |
| 312 | t.Parallel() |
| 313 | |
| 314 | matchingTokens := int64(64) |
| 315 | mismatchedTokens := int64(32) |
| 316 | model := &chattest.FakeModel{ProviderName: "test-provider", ModelName: "test-model"} |
| 317 | |
| 318 | tests := []struct { |
| 319 | name string |
| 320 | cfg chatadvisor.RuntimeConfig |
| 321 | errText string |
| 322 | }{ |
| 323 | { |
| 324 | name: "NilModel", |
| 325 | cfg: chatadvisor.RuntimeConfig{MaxUsesPerRun: 1, MaxOutputTokens: 64}, |
| 326 | errText: "advisor model is required", |
| 327 | }, |
| 328 | { |
| 329 | name: "NonPositiveMaxUses", |
| 330 | cfg: chatadvisor.RuntimeConfig{ |
| 331 | Model: model, |
| 332 | MaxUsesPerRun: 0, |
| 333 | MaxOutputTokens: 64, |
| 334 | }, |
| 335 | errText: "advisor max uses per run must be positive", |
| 336 | }, |
| 337 | { |
| 338 | name: "NonPositiveMaxOutputTokens", |
| 339 | cfg: chatadvisor.RuntimeConfig{ |
| 340 | Model: model, |
| 341 | MaxUsesPerRun: 1, |
| 342 | MaxOutputTokens: 0, |
| 343 | }, |
| 344 | errText: "advisor max output tokens must be positive", |
| 345 | }, |
| 346 | { |
| 347 | name: "MismatchedModelConfigMaxOutputTokens", |
| 348 | cfg: chatadvisor.RuntimeConfig{ |
| 349 | Model: model, |
| 350 | MaxUsesPerRun: 1, |
| 351 | MaxOutputTokens: matchingTokens, |
| 352 | ModelConfig: codersdk.ChatModelCallConfig{ |
| 353 | MaxOutputTokens: &mismatchedTokens, |
| 354 | }, |
| 355 | }, |
| 356 | errText: "must match runtime max output tokens", |
| 357 | }, |
| 358 | } |
| 359 | |
| 360 | for _, testCase := range tests { |
| 361 | t.Run(testCase.name, func(t *testing.T) { |
| 362 | t.Parallel() |
| 363 | |
| 364 | _, err := chatadvisor.NewRuntime(testCase.cfg) |
| 365 | require.Error(t, err) |
| 366 | require.ErrorContains(t, err, testCase.errText) |
| 367 | }) |
| 368 | } |
nothing calls this directly
no test coverage detected