Files
gastown/internal/cmd/nudge_test.go
markov-kernel e7145cfd77 fix: Make Mayor/Deacon session names include town name
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>
2026-01-03 21:37:05 +01:00

114 lines
3.0 KiB
Go

package cmd
import (
"testing"
)
func TestResolveNudgePattern(t *testing.T) {
// Create test agent sessions
agents := []*AgentSession{
{Name: "gt-ai-mayor", Type: AgentMayor, Town: "ai"},
{Name: "gt-ai-deacon", Type: AgentDeacon, Town: "ai"},
{Name: "gt-gastown-witness", Type: AgentWitness, Rig: "gastown"},
{Name: "gt-gastown-refinery", Type: AgentRefinery, Rig: "gastown"},
{Name: "gt-gastown-crew-max", Type: AgentCrew, Rig: "gastown", AgentName: "max"},
{Name: "gt-gastown-crew-jack", Type: AgentCrew, Rig: "gastown", AgentName: "jack"},
{Name: "gt-gastown-alpha", Type: AgentPolecat, Rig: "gastown", AgentName: "alpha"},
{Name: "gt-gastown-beta", Type: AgentPolecat, Rig: "gastown", AgentName: "beta"},
{Name: "gt-beads-witness", Type: AgentWitness, Rig: "beads"},
{Name: "gt-beads-gamma", Type: AgentPolecat, Rig: "beads", AgentName: "gamma"},
}
tests := []struct {
name string
pattern string
expected []string
}{
{
name: "mayor special case",
pattern: "mayor",
expected: []string{"gt-ai-mayor"},
},
{
name: "deacon special case",
pattern: "deacon",
expected: []string{"gt-ai-deacon"},
},
{
name: "specific witness",
pattern: "gastown/witness",
expected: []string{"gt-gastown-witness"},
},
{
name: "all witnesses",
pattern: "*/witness",
expected: []string{"gt-gastown-witness", "gt-beads-witness"},
},
{
name: "specific refinery",
pattern: "gastown/refinery",
expected: []string{"gt-gastown-refinery"},
},
{
name: "all polecats in rig",
pattern: "gastown/polecats/*",
expected: []string{"gt-gastown-alpha", "gt-gastown-beta"},
},
{
name: "specific polecat",
pattern: "gastown/polecats/alpha",
expected: []string{"gt-gastown-alpha"},
},
{
name: "all crew in rig",
pattern: "gastown/crew/*",
expected: []string{"gt-gastown-crew-max", "gt-gastown-crew-jack"},
},
{
name: "specific crew member",
pattern: "gastown/crew/max",
expected: []string{"gt-gastown-crew-max"},
},
{
name: "legacy polecat format",
pattern: "gastown/alpha",
expected: []string{"gt-gastown-alpha"},
},
{
name: "no matches",
pattern: "nonexistent/polecats/*",
expected: nil,
},
{
name: "invalid pattern",
pattern: "invalid",
expected: nil,
},
}
townName := "ai"
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := resolveNudgePattern(tt.pattern, agents, townName)
if len(got) != len(tt.expected) {
t.Errorf("resolveNudgePattern(%q) returned %d results, want %d: got %v, want %v",
tt.pattern, len(got), len(tt.expected), got, tt.expected)
return
}
// Check each expected value is present
gotMap := make(map[string]bool)
for _, g := range got {
gotMap[g] = true
}
for _, e := range tt.expected {
if !gotMap[e] {
t.Errorf("resolveNudgePattern(%q) missing expected %q, got %v",
tt.pattern, e, got)
}
}
})
}
}