MCPcopy Create free account
hub / github.com/astercloud/aster / TestCustomProvider

Function TestCustomProvider

pkg/provider/openai_compatible_test.go:259–288  ·  view source on GitHub ↗

TestCustomProvider 测试自定义 Provider(用户自带 Key 场景)

(t *testing.T)

Source from the content-addressed store, hash-verified

257
258// TestCustomProvider 测试自定义 Provider(用户自带 Key 场景)
259func 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 参数验证
291func TestCustomProviderValidation(t *testing.T) {

Callers

nothing calls this directly

Calls 4

NewCustomProviderFunction · 0.85
ConfigMethod · 0.65
CapabilitiesMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected