gateway tests: a Codex sign-in a test makes is listed at once, whichever test ran before (TestAccountProxy failed in the full package, passed alone) — usage: own was sent [], want [acct-1]: TestArrangedKeysAreGatewayCandidates, run just before, looked at the accounts in its own home, and provider.rememberLogins (internal/provider/logins.go:461) looks again only once 30s have passed since, so codexSignedIn's ~/.codex/auth.json for me@example.com was never taken into logins.json; the turn still went to acct-1 by Codex's own sign-in, but LoginUsage("codex") listed only the two saved accounts and never asked for acct-1's usage. codexSignedIn now calls provider.ForgetAccounts, made for a test's home, and again on cleanup, as fallback_test and refusal_accounts_test do. No production change: the 30s wait is magpie's own, and a sign-in or switch in magpie already clears it. go test -tags nogui -count=1 ./internal/gateway/ passes three times in a row; go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass.

This commit is contained in:
yetone committed 2026-10-02 04:22:18 +08:00
1 parent e4c8316e3f
commit 06caa0961d
1 file changed
+4
+4
View File
@@ -47,6 +47,10 @@ func codexSignedIn(t *testing.T, spares ...string) {
}
os.MkdirAll(filepath.Dir(provider.Path()), 0o755)
os.WriteFile(filepath.Join(filepath.Dir(provider.Path()), "logins.json"), mustJSON(saved), 0o600)
// signed in behind magpie's back: an earlier test's look at its own
// home within 30s would otherwise keep Codex's sign-in off the list
provider.ForgetAccounts()
t.Cleanup(provider.ForgetAccounts)
}
// usedUp stands in for the ChatGPT backend with acct-1 out of its