Files
gastown/internal/cmd/statusline_test.go
Steve Yegge 363a2c45ba fix(statusline): Count rigs from all agent types, not just polecats
- Rig count now includes rigs with any active sessions (witness, refinery, crew)
- Previously only counted rigs that had active polecat sessions
- Updated tests to use categorizeSession instead of removed helper functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 09:23:57 -08:00

83 lines
1.8 KiB
Go

package cmd
import "testing"
func TestCategorizeSessionRig(t *testing.T) {
tests := []struct {
session string
wantRig string
}{
// Standard polecat sessions
{"gt-gastown-slit", "gastown"},
{"gt-gastown-Toast", "gastown"},
{"gt-myrig-worker", "myrig"},
// Crew sessions
{"gt-gastown-crew-max", "gastown"},
{"gt-myrig-crew-user", "myrig"},
// Witness sessions
{"gt-gastown-witness", "gastown"},
{"gt-myrig-witness", "myrig"},
// Refinery sessions
{"gt-gastown-refinery", "gastown"},
{"gt-myrig-refinery", "myrig"},
// Edge cases
{"gt-a-b", "a"}, // minimum valid
// Town-level agents (no rig)
{"gt-mayor", ""},
{"gt-deacon", ""},
}
for _, tt := range tests {
t.Run(tt.session, func(t *testing.T) {
agent := categorizeSession(tt.session)
gotRig := ""
if agent != nil {
gotRig = agent.Rig
}
if gotRig != tt.wantRig {
t.Errorf("categorizeSession(%q).Rig = %q, want %q", tt.session, gotRig, tt.wantRig)
}
})
}
}
func TestCategorizeSessionType(t *testing.T) {
tests := []struct {
session string
wantType AgentType
}{
// Polecat sessions
{"gt-gastown-slit", AgentPolecat},
{"gt-gastown-Toast", AgentPolecat},
{"gt-myrig-worker", AgentPolecat},
{"gt-a-b", AgentPolecat},
// Non-polecat sessions
{"gt-gastown-witness", AgentWitness},
{"gt-gastown-refinery", AgentRefinery},
{"gt-gastown-crew-max", AgentCrew},
{"gt-myrig-crew-user", AgentCrew},
// Town-level agents
{"gt-mayor", AgentMayor},
{"gt-deacon", AgentDeacon},
}
for _, tt := range tests {
t.Run(tt.session, func(t *testing.T) {
agent := categorizeSession(tt.session)
if agent == nil {
t.Fatalf("categorizeSession(%q) returned nil", tt.session)
}
if agent.Type != tt.wantType {
t.Errorf("categorizeSession(%q).Type = %v, want %v", tt.session, agent.Type, tt.wantType)
}
})
}
}