movedAgent asked PluginServes(id) since cfa262509, so once a built-in
is retired sideLogins leaves the agent's own sign-in out as the
plugin's, though nothing has moved it. The mover's out() then never
lists it: MoveRetiring doesn't move it and MoveCandidates doesn't show
it in the Move line, so a user whose only account is the agent's own
(ZCode's, Kiro's, Grok's, ...) would be served by nothing once that
built-in is retired. movedAgent asks Moved(id) again: the own row is
set aside only after a real move.
New: TestRetiredOwnAccountStillMoves retires zcode in the test and
checks ZCode's own account is in its mover's list and in
MoveCandidates.
Run in this worktree (at 488ed5895 plus this change):
go test -tags nogui -count=1 -run TestRetiredOwnAccountStillMoves
./internal/provider: red with movedAgent back on PluginServes
("ZCode's own, retired and not moved: {User: ... Own:false}"),
green with the fix.
go test -tags nogui -count=1 -run 'Retired|Mover|Migrat|Move|
SideLogin|Own' ./internal/provider ./internal/gateway ./internal/cli
./internal/gui: ok (all four)
gofmt -l internal: nothing; go vet -tags nogui ./internal/provider
for darwin, linux, windows: clean.
Not run: whole packages, the full suite, the GUI suite (machine load
~300).
62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A retired built-in is its plugin's to serve before any move: signing in
|
|
// to the built-in is turned away, and only an id with a plugin can be
|
|
// retired. An id not retired is the plugin's only once moved.
|
|
func TestRetiredBuiltinIsThePlugins(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("XDG_CONFIG_HOME", home+"/.config")
|
|
id := ""
|
|
for m := range movers {
|
|
if !retiredBuiltins[m] {
|
|
id = m
|
|
break
|
|
}
|
|
}
|
|
if id == "" {
|
|
t.Skip("every built-in with a plugin is retired")
|
|
}
|
|
if PluginServes(id) {
|
|
t.Fatalf("%s is the plugin's with nothing moved or retired", id)
|
|
}
|
|
retiredBuiltins[id], retiredBuiltins["claude"] = true, true
|
|
t.Cleanup(func() { delete(retiredBuiltins, id); delete(retiredBuiltins, "claude") })
|
|
if !PluginServes(id) || !BuiltinRetired(id) {
|
|
t.Fatalf("retired %s isn't the plugin's", id)
|
|
}
|
|
if BuiltinRetired("claude") || PluginServes("claude") {
|
|
t.Fatal("claude, which has no plugin, is retired")
|
|
}
|
|
if _, err := StartSignInWith(id, SignInOptions{}); err == nil || !strings.Contains(err.Error(), "plugin") {
|
|
t.Fatalf("signing in to the retired built-in: %v", err)
|
|
}
|
|
}
|
|
|
|
// A retired built-in's accounts not moved yet are its mover's to take,
|
|
// the agent's own sign-in too: listed as the agent's own, not left out as
|
|
// the plugin's, until the move has run.
|
|
func TestRetiredOwnAccountStillMoves(t *testing.T) {
|
|
home := signIn(t)
|
|
was := retiredBuiltins["zcode"]
|
|
retiredBuiltins["zcode"] = true
|
|
t.Cleanup(func() { retiredBuiltins["zcode"] = was })
|
|
t.Setenv("ZCODE_CREDENTIAL_SECRET", "test-secret")
|
|
writeFile(t, filepath.Join(home, ".zcode", "v2", "credentials.json"), map[string]any{
|
|
"oauth:zai:user_info": zcodeEncrypt(t, `{"user_id":"u1","email":"own@example.com"}`),
|
|
"account-provider:coding-plan:account:zai-individual-coding-plan:account:abc:api-key": zcodeEncrypt(t, "own.secret"),
|
|
})
|
|
if own := movingOf(t, "zcode")["own@example.com"]; !own.Own {
|
|
t.Fatalf("ZCode's own, retired and not moved: %+v", own)
|
|
}
|
|
if c := MoveCandidates(); len(c) != 1 || c[0].ID != "zcode" || c[0].Accounts != 1 {
|
|
t.Fatalf("candidates: %+v", c)
|
|
}
|
|
}
|