返回 DeepSeek-Reasonix
provider_catalog_test.go
根目录 / desktop / provider_catalog_test.go
1 package main
2
3 import (
4 "reasonix/internal/config"
5 "testing"
6 )
7
8 func TestProviderCatalogViewsAndInstallPreserveExistingConnections(t *testing.T) {
9 isolateDesktopUserDirs(t)
10 a := NewApp()
11 if _, err := a.AddProviderPresetAccess("glm-coding-plan-cn", ""); err != nil {
12 t.Fatal(err)
13 }
14 before := config.LoadForEdit(config.UserConfigPath())
15 original, ok := before.Provider("glm-coding-plan-cn")
16 if !ok {
17 t.Fatal("missing original")
18 }
19 if _, err := a.AddProviderPresetAccess("openrouter", ""); err != nil {
20 t.Fatal(err)
21 }
22 after := config.LoadForEdit(config.UserConfigPath())
23 current, ok := after.Provider(original.Name)
24 if !ok || !config.ProviderEntriesConfigEqual(*original, *current) {
25 t.Fatal("adding another brand changed an existing connection")
26 }
27 views := a.Settings().ProviderPresets
28 found := false
29 for _, view := range views {
30 if view.ID == "glm-coding-plan-cn" {
31 found = true
32 if view.Catalog.BrandID != "zai" || view.Catalog.Product != "coding" || view.Catalog.Format != "openai" || view.Status != "installed" {
33 t.Fatalf("incorrect catalog view: %+v", view.Catalog)
34 }
35 }
36 }
37 if !found {
38 t.Fatal("missing installed route")
39 }
40 }
41
41 lines GO