返回 DeepSeek-Reasonix
provider_catalog_test.go
根目录 / internal / config / provider_catalog_test.go
1 package config
2
3 import (
4 "reflect"
5 "testing"
6 )
7
8 func TestProviderCatalogGroupsRoutesWithoutChangingPresets(t *testing.T) {
9 for _, tc := range []struct{ id, brand, region, product, format string }{
10 {"deepseek-responses", "deepseek", "global", "api", "responses"},
11 {"glm-cn", "zai", "cn", "api", "openai"},
12 {"glm-coding-plan-cn-anthropic", "zai", "cn", "coding", "anthropic"},
13 {"zai-coding-plan-global", "zai", "global", "coding", "openai"},
14 {"opencode-go-recommended", "opencode", "global", "go", "bundle"},
15 {"opencode-zen-anthropic", "opencode", "global", "zen", "anthropic"},
16 {"openai-responses", "openai", "global", "api", "responses"},
17 {"openai-chat", "openai", "global", "api", "openai"},
18 {"ollama-local", "ollama", "local", "local", "openai"},
19 {"ollama-cloud", "ollama", "global", "api", "openai"},
20 } {
21 p, ok := CuratedProviderPreset(tc.id)
22 if !ok {
23 t.Fatal(tc.id)
24 }
25 before := cloneProviderPreset(p)
26 c := CatalogForProviderPreset(p)
27 if c.BrandID != tc.brand || c.Region != tc.region || c.Product != tc.product || c.Format != tc.format {
28 t.Errorf("%s: %+v", tc.id, c)
29 }
30 if !reflect.DeepEqual(before, p) {
31 t.Fatalf("catalog changed existing preset %s", tc.id)
32 }
33 }
34 }
35
36 func TestExtendedProviderCatalogUsesSupportedAdaptersAndStableKeys(t *testing.T) {
37 for _, template := range extendedProviderPresets {
38 p, ok := CuratedProviderPreset(template.ID)
39 if !ok {
40 t.Fatal(template.ID)
41 }
42 e := p.Entries[0]
43 if e.APIKeyEnv == "" || !IsValidCredentialKey(e.APIKeyEnv) {
44 t.Fatalf("invalid key reference for %s", p.ID)
45 }
46 switch e.Kind {
47 case "openai", "anthropic", "responses":
48 default:
49 t.Fatalf("unsupported adapter %s", e.Kind)
50 }
51 if err := (&Config{}).UpsertProvider(e); err != nil {
52 t.Fatal(err)
53 }
54 if e.WebSearch == nil || *e.WebSearch {
55 t.Fatalf("unverified native search enabled for %s", p.ID)
56 }
57 }
58 for _, id := range []string{"ollama-local", "lmstudio"} {
59 p, _ := CuratedProviderPreset(id)
60 if p.Entries[0].RequiresAPIKey() {
61 t.Fatalf("local %s requires key", id)
62 }
63 }
64 }
65
65 lines GO