TestCustomProvider 测试自定义 Provider(用户自带 Key 场景)
(t *testing.T)
| 257 | |
| 258 | // TestCustomProvider 测试自定义 Provider(用户自带 Key 场景) |
| 259 | func TestCustomProvider(t *testing.T) { |
| 260 | config := &types.ModelConfig{ |
| 261 | Provider: "custom", |
| 262 | Model: "gpt-4o", |
| 263 | APIKey: "test-key", |
| 264 | BaseURL: "https://api.example.com/v1", |
| 265 | } |
| 266 | |
| 267 | provider, err := NewCustomProvider(config) |
| 268 | if err != nil { |
| 269 | t.Fatalf("Failed to create custom provider: %v", err) |
| 270 | } |
| 271 | |
| 272 | // 测试配置 |
| 273 | if provider.Config().Model != "gpt-4o" { |
| 274 | t.Errorf("Expected model=gpt-4o, got %s", provider.Config().Model) |
| 275 | } |
| 276 | |
| 277 | // 测试能力 |
| 278 | caps := provider.Capabilities() |
| 279 | if !caps.SupportStreaming { |
| 280 | t.Error("Custom provider should support streaming") |
| 281 | } |
| 282 | if !caps.SupportToolCalling { |
| 283 | t.Error("Custom provider should support tool calling") |
| 284 | } |
| 285 | if caps.ToolCallingFormat != "openai" { |
| 286 | t.Errorf("Expected ToolCallingFormat=openai, got %s", caps.ToolCallingFormat) |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | // TestCustomProviderValidation 测试自定义 Provider 参数验证 |
| 291 | func TestCustomProviderValidation(t *testing.T) { |
nothing calls this directly
no test coverage detected