test(provider): add tests for Alibaba Coding Plan protocol aliases
- Add tests for qwen-international, dashscope-intl, dashscope-us aliases - Add tests for coding-plan-anthropic and alibaba-coding-anthropic - Add getDefaultAPIBase tests for all new aliases - Add normalization tests for new provider aliases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b71bece170
commit
5eece48603
2 changed files with 139 additions and 0 deletions
|
|
@ -472,3 +472,134 @@ func TestCreateProviderFromConfig_AzureMissingAPIBase(t *testing.T) {
|
||||||
t.Fatal("CreateProviderFromConfig() expected error for missing API base")
|
t.Fatal("CreateProviderFromConfig() expected error for missing API base")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateProviderFromConfig_QwenInternationalAlias(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
protocol string
|
||||||
|
}{
|
||||||
|
{"qwen-international", "qwen-international"},
|
||||||
|
{"dashscope-intl", "dashscope-intl"},
|
||||||
|
{"qwen-intl", "qwen-intl"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cfg := &config.ModelConfig{
|
||||||
|
ModelName: "test-" + tt.protocol,
|
||||||
|
Model: tt.protocol + "/qwen-max",
|
||||||
|
APIKey: "test-key",
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, modelID, err := CreateProviderFromConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("CreateProviderFromConfig() error = %v", err)
|
||||||
|
}
|
||||||
|
if provider == nil {
|
||||||
|
t.Fatal("CreateProviderFromConfig() returned nil provider")
|
||||||
|
}
|
||||||
|
if modelID != "qwen-max" {
|
||||||
|
t.Errorf("modelID = %q, want %q", modelID, "qwen-max")
|
||||||
|
}
|
||||||
|
if _, ok := provider.(*HTTPProvider); !ok {
|
||||||
|
t.Fatalf("expected *HTTPProvider, got %T", provider)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateProviderFromConfig_QwenUSAlias(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
protocol string
|
||||||
|
}{
|
||||||
|
{"qwen-us", "qwen-us"},
|
||||||
|
{"dashscope-us", "dashscope-us"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cfg := &config.ModelConfig{
|
||||||
|
ModelName: "test-" + tt.protocol,
|
||||||
|
Model: tt.protocol + "/qwen-max",
|
||||||
|
APIKey: "test-key",
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, modelID, err := CreateProviderFromConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("CreateProviderFromConfig() error = %v", err)
|
||||||
|
}
|
||||||
|
if provider == nil {
|
||||||
|
t.Fatal("CreateProviderFromConfig() returned nil provider")
|
||||||
|
}
|
||||||
|
if modelID != "qwen-max" {
|
||||||
|
t.Errorf("modelID = %q, want %q", modelID, "qwen-max")
|
||||||
|
}
|
||||||
|
if _, ok := provider.(*HTTPProvider); !ok {
|
||||||
|
t.Fatalf("expected *HTTPProvider, got %T", provider)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateProviderFromConfig_CodingPlanAnthropic(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
protocol string
|
||||||
|
}{
|
||||||
|
{"coding-plan-anthropic", "coding-plan-anthropic"},
|
||||||
|
{"alibaba-coding-anthropic", "alibaba-coding-anthropic"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
cfg := &config.ModelConfig{
|
||||||
|
ModelName: "test-" + tt.protocol,
|
||||||
|
Model: tt.protocol + "/claude-sonnet-4-20250514",
|
||||||
|
APIKey: "test-key",
|
||||||
|
}
|
||||||
|
|
||||||
|
provider, modelID, err := CreateProviderFromConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("CreateProviderFromConfig() error = %v", err)
|
||||||
|
}
|
||||||
|
if provider == nil {
|
||||||
|
t.Fatal("CreateProviderFromConfig() returned nil provider")
|
||||||
|
}
|
||||||
|
if modelID != "claude-sonnet-4-20250514" {
|
||||||
|
t.Errorf("modelID = %q, want %q", modelID, "claude-sonnet-4-20250514")
|
||||||
|
}
|
||||||
|
// coding-plan-anthropic uses Anthropic Messages provider
|
||||||
|
// Verify it's the anthropic messages provider by checking interface
|
||||||
|
var _ LLMProvider = provider
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetDefaultAPIBase_CodingPlanAnthropic(t *testing.T) {
|
||||||
|
expectedURL := "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic"
|
||||||
|
if got := getDefaultAPIBase("coding-plan-anthropic"); got != expectedURL {
|
||||||
|
t.Fatalf("getDefaultAPIBase(%q) = %q, want %q", "coding-plan-anthropic", got, expectedURL)
|
||||||
|
}
|
||||||
|
if got := getDefaultAPIBase("alibaba-coding-anthropic"); got != expectedURL {
|
||||||
|
t.Fatalf("getDefaultAPIBase(%q) = %q, want %q", "alibaba-coding-anthropic", got, expectedURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetDefaultAPIBase_QwenIntlAliases(t *testing.T) {
|
||||||
|
expectedURL := "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
||||||
|
for _, protocol := range []string{"qwen-intl", "qwen-international", "dashscope-intl"} {
|
||||||
|
if got := getDefaultAPIBase(protocol); got != expectedURL {
|
||||||
|
t.Fatalf("getDefaultAPIBase(%q) = %q, want %q", protocol, got, expectedURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetDefaultAPIBase_QwenUSAliases(t *testing.T) {
|
||||||
|
expectedURL := "https://dashscope-us.aliyuncs.com/compatible-mode/v1"
|
||||||
|
for _, protocol := range []string{"qwen-us", "dashscope-us"} {
|
||||||
|
if got := getDefaultAPIBase(protocol); got != expectedURL {
|
||||||
|
t.Fatalf("getDefaultAPIBase(%q) = %q, want %q", protocol, got, expectedURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,14 @@ func TestNormalizeProvider(t *testing.T) {
|
||||||
{"glm", "zhipu"},
|
{"glm", "zhipu"},
|
||||||
{"google", "gemini"},
|
{"google", "gemini"},
|
||||||
{"groq", "groq"},
|
{"groq", "groq"},
|
||||||
|
// Alibaba Coding Plan aliases
|
||||||
|
{"alibaba-coding", "coding-plan"},
|
||||||
|
{"qwen-coding", "coding-plan"},
|
||||||
|
{"alibaba-coding-anthropic", "coding-plan-anthropic"},
|
||||||
|
// Qwen international aliases
|
||||||
|
{"qwen-international", "qwen-intl"},
|
||||||
|
{"dashscope-intl", "qwen-intl"},
|
||||||
|
{"dashscope-us", "qwen-us"},
|
||||||
{"", ""},
|
{"", ""},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue