MCPcopy Index your code
hub / github.com/coder/coder / TestValidateLegacyAIBridgeConfig

Function TestValidateLegacyAIBridgeConfig

cli/server_aibridge_internal_test.go:510–577  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

508}
509
510func TestValidateLegacyAIBridgeConfig(t *testing.T) {
511 t.Parallel()
512
513 tests := []struct {
514 name string
515 cfg codersdk.AIBridgeConfig
516 errContains string
517 }{
518 {
519 name: "BareAnthropicKey",
520 cfg: codersdk.AIBridgeConfig{
521 LegacyAnthropic: codersdk.AIBridgeAnthropicConfig{Key: "sk-ant"},
522 },
523 },
524 {
525 name: "BareBedrockRegion",
526 cfg: codersdk.AIBridgeConfig{
527 LegacyBedrock: codersdk.AIBridgeBedrockConfig{Region: "us-east-1"},
528 },
529 },
530 {
531 name: "BedrockCredentialsOnly",
532 cfg: codersdk.AIBridgeConfig{
533 LegacyBedrock: codersdk.AIBridgeBedrockConfig{
534 AccessKey: "AKIA",
535 AccessKeySecret: "secret",
536 },
537 },
538 },
539 {
540 name: "AnthropicKeyAndBedrockConflict",
541 cfg: codersdk.AIBridgeConfig{
542 LegacyAnthropic: codersdk.AIBridgeAnthropicConfig{Key: "sk-ant"},
543 LegacyBedrock: codersdk.AIBridgeBedrockConfig{
544 Region: "us-east-1",
545 AccessKey: "AKIA",
546 AccessKeySecret: "secret",
547 },
548 },
549 errContains: "CODER_AIBRIDGE_ANTHROPIC_KEY and CODER_AIBRIDGE_BEDROCK_* are mutually exclusive",
550 },
551 {
552 name: "AnthropicKeyWithBedrockModelDefaultsIsFine",
553 cfg: codersdk.AIBridgeConfig{
554 LegacyAnthropic: codersdk.AIBridgeAnthropicConfig{Key: "sk-ant"},
555 // Model defaults shouldn't trip the conflict; they're
556 // always populated in a real deployment.
557 LegacyBedrock: codersdk.AIBridgeBedrockConfig{
558 Model: "anthropic.claude-3-5-sonnet",
559 SmallFastModel: "anthropic.claude-3-5-haiku",
560 },
561 },
562 },
563 }
564
565 for _, tt := range tests {
566 t.Run(tt.name, func(t *testing.T) {
567 t.Parallel()

Callers

nothing calls this directly

Calls 4

RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected