Files
magpie/internal/agent/connect_group_test.go
T
yetone 58ecd4454c davsync, agent: sync turned off and on again to the same server keeps what changed here, and an agent shown only routing groups connects on the first (#939, aiirobyte)
Off deleted sync-state.json, so turning sync on again made this computer a
new one: the first sync brought the server's whole setup in over it, and
every agent changed while sync was off went back to the server's older
fields. Off now keeps what this computer last synced (dropping only the
error, notice, undo and usage state), so it resumes: changes here go up.
TestOffAndOnAgainKeepsChangesHere fails without it (Codex's model went
back to "gpt-old").

The Agents switch said "magpie has no models Codex can use" when the only
models shown to the agent were routing groups (its own ChatGPT account's
are left out of Codex's list), while `magpie codex group/folia-1` worked.
Connect now falls back to the first routing group.
TestConnectOnARoutingGroupAlone fails without it.
2026-10-06 02:16:08 +08:00

38 lines
1.2 KiB
Go

package agent
import (
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/settings"
)
// An agent whose only models through magpie are routing groups is
// connected on the first of them (#939: the switch said magpie had no
// models Codex could use while `magpie codex group/folia-1` connected it).
func TestConnectOnARoutingGroupAlone(t *testing.T) {
home, _ := codexHome(t, "", "")
if err := provider.Save(provider.Provider{ID: "aaa", Name: "AAA", Chat: "https://a.example/v1", Key: "k", Models: []string{"m1"}}); err != nil {
t.Fatal(err)
}
if err := provider.SaveGroup(provider.Group{ID: "folia-1", Name: "folia-1", Members: []string{"aaa/m1"}}); err != nil {
t.Fatal(err)
}
s := settings.Load()
s.HiddenModels = map[string][]string{"claude": {"aaa/m1", "fake/m1"}}
if err := settings.Save(s); err != nil {
t.Fatal(err)
}
path := filepath.Join(home, ".claude", "settings.json")
writeFile(t, path, `{}`)
c := claude(home)
if err := c.Connect(); err != nil {
t.Fatal(err)
}
if m, _ := edit.GetJSON(path, "model"); m != "group/folia-1" {
t.Fatalf("connected on %q:\n%s", m, readFile(path))
}
}