package validate import ( "path/filepath" "testing" "thehouseoficarus/internal/behavior" ) // TestDropTableCycleIsAnError: a self/mutual drop-table reference must be a // startup ERROR, because ResolveDrop recurses and would otherwise overflow the // goroutine stack at runtime. func TestDropTableCycleIsAnError(t *testing.T) { dir := t.TempDir() writeFile(t, filepath.Join(dir, "drops", "a.yaml"), "id: a\ndrops:\n - table: b\n weight: 1\n") writeFile(t, filepath.Join(dir, "drops", "b.yaml"), "id: b\ndrops:\n - table: a\n weight: 1\n") behavior.ClearDropIndex() defer behavior.ClearDropIndex() issues := validateDropTableCycles(Source{DataDir: dir}, dropTableIDSet(dir)) if len(issues) == 0 { t.Fatal("expected a cycle error for a <-> b") } for _, issue := range issues { if issue.Level != "ERROR" { t.Fatalf("cycle issue must be ERROR: %+v", issue) } } } // TestNonNumericRoomFilenameIsAnError: the room index only accepts numeric // stems, so a backup file must be flagged instead of silently ignored. func TestNonNumericRoomFilenameIsAnError(t *testing.T) { dir := t.TempDir() writeFile(t, filepath.Join(dir, "rooms", "1001.yaml"), "id: 1001\nname: real\n") writeFile(t, filepath.Join(dir, "rooms", "1001_copy.yaml"), "id: 1001\nname: copy\n") issues := validateRoomFilenames(dir) if len(issues) != 1 { t.Fatalf("expected exactly one filename issue, got %+v", issues) } if issues[0].Level != "ERROR" { t.Fatalf("expected ERROR, got %+v", issues[0]) } }