a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package agents
|
|
|
|
import "testing"
|
|
|
|
// TestMCPArgsConvergeOnMcp asserts the shared MCP entries emit the single
|
|
// canonical ["mcp"] args shape (no --index/--watch/--proxy).
|
|
func TestMCPArgsConvergeOnMcp(t *testing.T) {
|
|
for name, entry := range map[string]map[string]any{
|
|
"default": DefaultGortexMCPEntry(),
|
|
"global": GlobalGortexMCPEntry(),
|
|
} {
|
|
args, _ := entry["args"].([]string)
|
|
if len(args) != 1 || args[0] != "mcp" {
|
|
t.Errorf("%s entry args = %v, want [mcp]", name, args)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestUpsertMigratesLegacyShapes asserts the upsert rewrites every legacy
|
|
// on-disk args shape to the canonical ["mcp"] on first run, and is a no-op
|
|
// on the second run (idempotent, self-healing).
|
|
func TestUpsertMigratesLegacyShapes(t *testing.T) {
|
|
legacy := map[string][]any{
|
|
"index-watch": {"mcp", "--index", ".", "--watch"},
|
|
"proxy": {"mcp", "--proxy"},
|
|
}
|
|
for name, args := range legacy {
|
|
t.Run(name, func(t *testing.T) {
|
|
root := map[string]any{
|
|
"mcpServers": map[string]any{
|
|
"gortex": map[string]any{"command": "gortex", "args": args},
|
|
},
|
|
}
|
|
if changed := UpsertMCPServerWithMigration(root, "gortex", DefaultGortexMCPEntry(), ApplyOpts{}); !changed {
|
|
t.Fatal("first upsert should migrate a legacy stanza")
|
|
}
|
|
got := root["mcpServers"].(map[string]any)["gortex"].(map[string]any)["args"]
|
|
gotArgs, _ := got.([]string)
|
|
if len(gotArgs) != 1 || gotArgs[0] != "mcp" {
|
|
t.Fatalf("migrated args = %v, want [mcp]", got)
|
|
}
|
|
if changed := UpsertMCPServerWithMigration(root, "gortex", DefaultGortexMCPEntry(), ApplyOpts{}); changed {
|
|
t.Fatal("second upsert must be a no-op (already canonical)")
|
|
}
|
|
})
|
|
}
|
|
}
|