Warn when circumventing class spellbooks

This commit is contained in:
2026-05-26 18:37:59 +02:00
parent 16ed4fe47d
commit b7587cfd05
2 changed files with 113 additions and 0 deletions
+35
View File
@@ -13626,6 +13626,41 @@ func TestValidateProjectRejectsInvalidClassSpellbooks(t *testing.T) {
}
}
func TestValidateProjectWarnsWhenSpellModuleAuthorsManagedSpellbookColumn(t *testing.T) {
root := testProjectRoot(t)
writeMinimalSpellbookProject(t, root)
mkdirAll(t, filepath.Join(root, "topdata", "data", "spells", "modules"))
writeFile(t, filepath.Join(root, "topdata", "data", "classes", "spellbooks", "bard.json"), `{
"key": "classes/spellbooks:bard",
"class": "classes:bard",
"levels": {
"0": ["spells:flare"]
}
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "spells", "modules", "direct_class_column.json"), `{
"columns": ["Sorcerer"],
"entries": {
"spells:module_spell": {
"Label": "ModuleSpell",
"Bard": 1,
"Sorcerer": 1
}
}
}`+"\n")
report := ValidateProject(testProject(root))
if report.HasErrors() {
t.Fatalf("expected warning-only validation result, got errors:\n%s", diagnosticsText(report.Diagnostics))
}
text := diagnosticsText(report.Diagnostics)
if !strings.Contains(text, `spell module authors class spell column "Bard" managed by class spellbook`) {
t.Fatalf("expected managed Bard column warning, got:\n%s", text)
}
if !strings.Contains(text, `use topdata/data/classes/spellbooks/bard.json instead`) {
t.Fatalf("expected warning to point at spellbook file, got:\n%s", text)
}
}
func TestValidateProjectDoesNotRewritePlainDatasetLockfile(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "ruleset"))