TestCustomProviderValidation 测试自定义 Provider 参数验证
(t *testing.T)
| 289 | |
| 290 | // TestCustomProviderValidation 测试自定义 Provider 参数验证 |
| 291 | func TestCustomProviderValidation(t *testing.T) { |
| 292 | // 缺少 BaseURL |
| 293 | config := &types.ModelConfig{ |
| 294 | Provider: "custom", |
| 295 | Model: "gpt-4o", |
| 296 | APIKey: "test-key", |
| 297 | } |
| 298 | |
| 299 | _, err := NewCustomProvider(config) |
| 300 | if err == nil { |
| 301 | t.Error("Expected error when BaseURL is missing") |
| 302 | } |
| 303 | |
| 304 | // 缺少 APIKey |
| 305 | config = &types.ModelConfig{ |
| 306 | Provider: "custom", |
| 307 | Model: "gpt-4o", |
| 308 | BaseURL: "https://api.example.com/v1", |
| 309 | } |
| 310 | |
| 311 | _, err = NewCustomProvider(config) |
| 312 | if err == nil { |
| 313 | t.Error("Expected error when APIKey is missing") |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | // TestProviderFactory 测试工厂模式 |
| 318 | func TestProviderFactory(t *testing.T) { |
nothing calls this directly
no test coverage detected