Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions anthropic_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aibridge

import (
"context"
"encoding/json"
"testing"

Expand Down Expand Up @@ -184,6 +185,114 @@ func TestShouldConvertContentField(t *testing.T) {
}
}

func TestAWSBedrockValidation(t *testing.T) {
t.Parallel()

tests := []struct {
name string
cfg *AWSBedrockConfig
expectError bool
errorMsg string
}{
{
name: "valid",
cfg: &AWSBedrockConfig{
Region: "us-east-1",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "test-model",
SmallFastModel: "test-small-model",
},
},
{
name: "missing region",
cfg: &AWSBedrockConfig{
Region: "",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "test-model",
SmallFastModel: "test-small-model",
},
expectError: true,
errorMsg: "region required",
},
{
name: "missing access key",
cfg: &AWSBedrockConfig{
Region: "us-east-1",
AccessKey: "",
AccessKeySecret: "test-secret",
Model: "test-model",
SmallFastModel: "test-small-model",
},
expectError: true,
errorMsg: "access key required",
},
{
name: "missing access key secret",
cfg: &AWSBedrockConfig{
Region: "us-east-1",
AccessKey: "test-key",
AccessKeySecret: "",
Model: "test-model",
SmallFastModel: "test-small-model",
},
expectError: true,
errorMsg: "access key secret required",
},
{
name: "missing model",
cfg: &AWSBedrockConfig{
Region: "us-east-1",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "",
SmallFastModel: "test-small-model",
},
expectError: true,
errorMsg: "model required",
},
{
name: "missing small fast model",
cfg: &AWSBedrockConfig{
Region: "us-east-1",
AccessKey: "test-key",
AccessKeySecret: "test-secret",
Model: "test-model",
SmallFastModel: "",
},
expectError: true,
errorMsg: "small fast model required",
},
{
name: "all fields empty",
cfg: &AWSBedrockConfig{},
expectError: true,
errorMsg: "region required",
},
{
name: "nil config",
cfg: nil,
expectError: true,
errorMsg: "nil config given",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
base := &AnthropicMessagesInterceptionBase{}
_, err := base.withAWSBedrock(context.Background(), tt.cfg)

if tt.expectError {
require.Error(t, err)
require.Contains(t, err.Error(), tt.errorMsg)
} else {
require.NoError(t, err)
}
})
}
}

func TestAccumulateUsage(t *testing.T) {
t.Run("Usage to Usage", func(t *testing.T) {
dest := &anthropic.Usage{
Expand Down
Loading