* test: Add test coverage for 16 files (40.3% -> 45.5%) Add comprehensive tests for previously untested packages: - internal/agent/state_test.go - internal/cmd/errors_test.go - internal/crew/types_test.go - internal/doctor/errors_test.go - internal/dog/types_test.go - internal/mail/bd_test.go - internal/opencode/plugin_test.go - internal/rig/overlay_test.go - internal/runtime/runtime_test.go - internal/session/town_test.go - internal/style/style_test.go - internal/ui/markdown_test.go - internal/ui/terminal_test.go - internal/wisp/io_test.go - internal/wisp/types_test.go - internal/witness/types_test.go style_test.go uses func(...string) to match lipgloss variadic Render signature. * fix(lint): remove unused error return from buildCVSummary buildCVSummary always returned nil for its error value, causing golangci-lint to fail with "result 1 (error) is always nil". The function handles errors internally by returning partial data, so the error return was misleading. Removed it and updated caller.
94 lines
2.3 KiB
Go
94 lines
2.3 KiB
Go
package session
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTownSessions(t *testing.T) {
|
|
sessions := TownSessions()
|
|
|
|
if len(sessions) != 3 {
|
|
t.Errorf("TownSessions() returned %d sessions, want 3", len(sessions))
|
|
}
|
|
|
|
// Verify order is correct (Mayor, Boot, Deacon)
|
|
expectedOrder := []string{"Mayor", "Boot", "Deacon"}
|
|
for i, s := range sessions {
|
|
if s.Name != expectedOrder[i] {
|
|
t.Errorf("TownSessions()[%d].Name = %q, want %q", i, s.Name, expectedOrder[i])
|
|
}
|
|
if s.SessionID == "" {
|
|
t.Errorf("TownSessions()[%d].SessionID should not be empty", i)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTownSessions_SessionIDFormats(t *testing.T) {
|
|
sessions := TownSessions()
|
|
|
|
for _, s := range sessions {
|
|
if s.SessionID == "" {
|
|
t.Errorf("TownSession %q has empty SessionID", s.Name)
|
|
}
|
|
// Session IDs should follow a pattern
|
|
if len(s.SessionID) < 4 {
|
|
t.Errorf("TownSession %q SessionID %q is too short", s.Name, s.SessionID)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTownSession_StructFields(t *testing.T) {
|
|
ts := TownSession{
|
|
Name: "Test",
|
|
SessionID: "test-session",
|
|
}
|
|
|
|
if ts.Name != "Test" {
|
|
t.Errorf("TownSession.Name = %q, want %q", ts.Name, "Test")
|
|
}
|
|
if ts.SessionID != "test-session" {
|
|
t.Errorf("TownSession.SessionID = %q, want %q", ts.SessionID, "test-session")
|
|
}
|
|
}
|
|
|
|
func TestTownSession_CanBeCreated(t *testing.T) {
|
|
// Test that TownSession can be created with any values
|
|
tests := []struct {
|
|
name string
|
|
sessionID string
|
|
}{
|
|
{"Mayor", "hq-mayor"},
|
|
{"Boot", "hq-boot"},
|
|
{"Custom", "custom-session"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
ts := TownSession{
|
|
Name: tt.name,
|
|
SessionID: tt.sessionID,
|
|
}
|
|
if ts.Name != tt.name {
|
|
t.Errorf("TownSession.Name = %q, want %q", ts.Name, tt.name)
|
|
}
|
|
if ts.SessionID != tt.sessionID {
|
|
t.Errorf("TownSession.SessionID = %q, want %q", ts.SessionID, tt.sessionID)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTownSession_ShutdownOrder(t *testing.T) {
|
|
// Verify that shutdown order is Mayor -> Boot -> Deacon
|
|
// This is critical because Boot monitors Deacon
|
|
sessions := TownSessions()
|
|
|
|
if sessions[0].Name != "Mayor" {
|
|
t.Errorf("First session should be Mayor, got %q", sessions[0].Name)
|
|
}
|
|
if sessions[1].Name != "Boot" {
|
|
t.Errorf("Second session should be Boot, got %q", sessions[1].Name)
|
|
}
|
|
if sessions[2].Name != "Deacon" {
|
|
t.Errorf("Third session should be Deacon, got %q", sessions[2].Name)
|
|
}
|
|
}
|