test: Add comprehensive test coverage for patrol roles check

- Add GetAllRoleTemplates tests (basic and content validity)
- Add FixMultipleRigs test for multi-rig fix scenario
- Add DetailsFormat test verifying rig:template prefix format
- Add MalformedRigsJSON test for error handling
- Add EmptyRigsConfig test for edge case
This commit is contained in:
Avyukth
2026-01-03 00:37:08 +05:30
parent 3e5562222d
commit 19be078618
2 changed files with 154 additions and 0 deletions

View File

@@ -188,3 +188,51 @@ func TestRoleNames(t *testing.T) {
}
}
}
func TestGetAllRoleTemplates(t *testing.T) {
templates, err := GetAllRoleTemplates()
if err != nil {
t.Fatalf("GetAllRoleTemplates() error = %v", err)
}
if len(templates) == 0 {
t.Fatal("GetAllRoleTemplates() returned empty map")
}
expectedFiles := []string{
"deacon.md.tmpl",
"witness.md.tmpl",
"refinery.md.tmpl",
"mayor.md.tmpl",
"polecat.md.tmpl",
"crew.md.tmpl",
}
for _, file := range expectedFiles {
content, ok := templates[file]
if !ok {
t.Errorf("GetAllRoleTemplates() missing %s", file)
continue
}
if len(content) == 0 {
t.Errorf("GetAllRoleTemplates()[%s] has empty content", file)
}
}
}
func TestGetAllRoleTemplates_ContentValidity(t *testing.T) {
templates, err := GetAllRoleTemplates()
if err != nil {
t.Fatalf("GetAllRoleTemplates() error = %v", err)
}
for name, content := range templates {
if !strings.HasSuffix(name, ".md.tmpl") {
t.Errorf("unexpected file %s (should end with .md.tmpl)", name)
}
contentStr := string(content)
if !strings.Contains(contentStr, "Context") {
t.Errorf("%s doesn't contain 'Context' - may not be a valid role template", name)
}
}
}