Session names `gt-mayor` and `gt-deacon` were hardcoded, causing tmux
session name collisions when running multiple towns simultaneously.
Changed to `gt-{town}-mayor` and `gt-{town}-deacon` format (e.g.,
`gt-ai-mayor`) to allow concurrent multi-town operation.
Key changes:
- session.MayorSessionName() and DeaconSessionName() now take townName param
- Added workspace.GetTownName() helper to load town name from config
- Updated all callers in cmd/, daemon/, doctor/, mail/, rig/, templates/
- Updated tests with new session name format
- Bead IDs remain unchanged (already scoped by .beads/ directory)
Fixes #60
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
119 lines
2.5 KiB
Go
119 lines
2.5 KiB
Go
package cmd
|
|
|
|
import "testing"
|
|
|
|
func TestParsePolecatSessionName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
sessionName string
|
|
wantRig string
|
|
wantPolecat string
|
|
wantOk bool
|
|
}{
|
|
// Valid polecat sessions
|
|
{
|
|
name: "simple polecat",
|
|
sessionName: "gt-greenplace-Toast",
|
|
wantRig: "greenplace",
|
|
wantPolecat: "Toast",
|
|
wantOk: true,
|
|
},
|
|
{
|
|
name: "another polecat",
|
|
sessionName: "gt-greenplace-Nux",
|
|
wantRig: "greenplace",
|
|
wantPolecat: "Nux",
|
|
wantOk: true,
|
|
},
|
|
{
|
|
name: "polecat in different rig",
|
|
sessionName: "gt-beads-Worker",
|
|
wantRig: "beads",
|
|
wantPolecat: "Worker",
|
|
wantOk: true,
|
|
},
|
|
{
|
|
name: "polecat with hyphen in name",
|
|
sessionName: "gt-greenplace-Max-01",
|
|
wantRig: "greenplace",
|
|
wantPolecat: "Max-01",
|
|
wantOk: true,
|
|
},
|
|
|
|
// Not polecat sessions (should return false)
|
|
{
|
|
name: "crew session",
|
|
sessionName: "gt-greenplace-crew-jack",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "witness session",
|
|
sessionName: "gt-greenplace-witness",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "refinery session",
|
|
sessionName: "gt-greenplace-refinery",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "mayor session",
|
|
sessionName: "gt-ai-mayor",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "deacon session",
|
|
sessionName: "gt-ai-deacon",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "no gt prefix",
|
|
sessionName: "gastown-Toast",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "empty string",
|
|
sessionName: "",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "just gt prefix",
|
|
sessionName: "gt-",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
{
|
|
name: "no name after rig",
|
|
sessionName: "gt-greenplace-",
|
|
wantRig: "",
|
|
wantPolecat: "",
|
|
wantOk: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
gotRig, gotPolecat, gotOk := parsePolecatSessionName(tt.sessionName)
|
|
if gotRig != tt.wantRig || gotPolecat != tt.wantPolecat || gotOk != tt.wantOk {
|
|
t.Errorf("parsePolecatSessionName(%q) = (%q, %q, %v), want (%q, %q, %v)",
|
|
tt.sessionName, gotRig, gotPolecat, gotOk, tt.wantRig, tt.wantPolecat, tt.wantOk)
|
|
}
|
|
})
|
|
}
|
|
}
|