Files
magpie/model_suffix_cli_test.go
yetone 4547dafe95 models: Provider in model names has a third way, a name the user gave used just as they wrote it (#92 marsxxl: v0.1.591 的 Codex 下拉里自定义名称又带上了 · WorkBuddy / · Claude Code) — 559ce021 (#203) had a custom name keep " · <provider>" after it like any other, so "Opus 5.5" read "Opus 5.5 · Claude Code" in every list Labels feeds (Codex's model_catalog_json and the gateway's Codex /models, Pi's, OpenCode's, ZCode's, OMP's, Muse's), while #92 had been promised the name as written. Both are kept: the setting is now Off / Not on names I set (自定义名称不带供应商) / On. On stays the default and keeps #203's behaviour, so nobody's list changes unasked; own leaves a name the user gave as it is and a vendor's name with its provider's; off is #335's plain names. Stored as plainOwnNames beside plainNames, so a settings.json of before reads as it did (plainNames: true is off). POST /api/settings/plain-names takes mode on|own|off (a body of on alone still works), magpie model suffix on|own|off, a Settings save keeps it, and /v1/models' magpie_label now follows the setting through Labels as the agents' lists do. The row's hint is one line that fits (en, zh), and its zh name says 供应商 as the rest of the app. Prompts and headers are unchanged. TestSuffixMode, TestSuffixModesReachAgentFiles (Codex model_catalog_json and Pi models.json), TestModelsListSuffixModes (/v1/models magpie_label) and model-suffix-own.test.cjs (Chromium and WebKit, en and zh) fail without the change; TestModelName and TestModelNameAndLevelsReachAgentFiles keep #203's assertions. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestConfiguredModelsAdvertiseImageInput load-flaky, passes alone); plain-names, click-scroll, old-webkit pass.
2026-10-01 23:20:57 +08:00

44 lines
1.4 KiB
Go

package main
import (
"testing"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/settings"
)
// magpie model suffix off has the agents' lists name models alone, on
// names them with their providers again (#335), own all but the names the
// user gave (#92); anything else is refused.
func TestModelSuffixCmd(t *testing.T) {
groupsHome(t)
catalog.Changed = nil // no agent's files are rewritten here
if err := modelCmd([]string{"suffix"}); err != nil {
t.Fatal(err)
}
if err := modelCmd([]string{"suffix", "off"}); err != nil || !settings.Load().PlainNames {
t.Fatal(err, settings.Load().PlainNames)
}
if err := modelCmd([]string{"suffix"}); err != nil {
t.Fatal(err)
}
if err := modelCmd([]string{"suffix", "on"}); err != nil || settings.Load().PlainNames {
t.Fatal(err, settings.Load().PlainNames)
}
// own: a name the user gave just as they wrote it, the others with
// their provider's (#92)
if err := modelCmd([]string{"suffix", "own"}); err != nil || provider.SuffixMode() != provider.SuffixOwn {
t.Fatal(err, provider.SuffixMode())
}
if err := modelCmd([]string{"suffix"}); err != nil {
t.Fatal(err)
}
if err := modelCmd([]string{"suffix", "on"}); err != nil || provider.SuffixMode() != provider.SuffixOn {
t.Fatal(err, provider.SuffixMode())
}
if err := modelCmd([]string{"suffix", "maybe"}); err == nil {
t.Fatal("took maybe")
}
}