package cmd import ( "testing" ) func TestExtractPatrolRole(t *testing.T) { tests := []struct { name string title string expected string }{ { name: "deacon patrol", title: "Digest: mol-deacon-patrol", expected: "deacon", }, { name: "witness patrol", title: "Digest: mol-witness-patrol", expected: "witness", }, { name: "refinery patrol", title: "Digest: mol-refinery-patrol", expected: "refinery", }, { name: "wisp digest without patrol suffix", title: "Digest: gt-wisp-abc123", expected: "patrol", }, { name: "random title", title: "Some other digest", expected: "patrol", }, { name: "empty title", title: "", expected: "patrol", }, { name: "just digest prefix", title: "Digest: ", expected: "patrol", }, { name: "mol prefix but no patrol suffix", title: "Digest: mol-deacon-other", expected: "patrol", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := extractPatrolRole(tt.title) if got != tt.expected { t.Errorf("extractPatrolRole(%q) = %q, want %q", tt.title, got, tt.expected) } }) } } func TestPatrolDigestDateFormat(t *testing.T) { // Test that PatrolDigest.Date format is YYYY-MM-DD digest := PatrolDigest{ Date: "2026-01-17", TotalCycles: 5, ByRole: map[string]int{"deacon": 2, "witness": 3}, } if digest.Date != "2026-01-17" { t.Errorf("Date format incorrect: got %q", digest.Date) } if digest.TotalCycles != 5 { t.Errorf("TotalCycles: got %d, want 5", digest.TotalCycles) } if digest.ByRole["deacon"] != 2 { t.Errorf("ByRole[deacon]: got %d, want 2", digest.ByRole["deacon"]) } } func TestPatrolCycleEntry(t *testing.T) { entry := PatrolCycleEntry{ ID: "gt-abc123", Role: "deacon", Title: "Digest: mol-deacon-patrol", Description: "Test description", } if entry.ID != "gt-abc123" { t.Errorf("ID: got %q, want %q", entry.ID, "gt-abc123") } if entry.Role != "deacon" { t.Errorf("Role: got %q, want %q", entry.Role, "deacon") } }