Fix validator screaming about new columns

This commit is contained in:
2026-05-24 12:06:47 +02:00
parent 334cd427c0
commit 91ab34ddff
2 changed files with 97 additions and 23 deletions
+45
View File
@@ -134,6 +134,51 @@ func TestValidateProjectRejectsDuplicateJSONKeys(t *testing.T) {
}
}
func TestValidateProjectAcceptsModuleColumnExpansionFile(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules"))
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "base.json"), `{
"output": "racialtypes.2da",
"columns": ["Label"],
"rows": []
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules", "00_newcolumns.json"), `{
"columns": ["ECL", "AvailableHeadsMale", "AvailableSkinColors"]
}`+"\n")
report := ValidateProject(testProject(root))
text := diagnosticsText(report.Diagnostics)
if strings.Contains(text, "module file does not use a recognized canonical shape") {
t.Fatalf("expected module column expansion file to validate as canonical, got:\n%s", text)
}
if report.HasErrors() {
t.Fatalf("expected module column expansion file to avoid validation errors, got:\n%s", text)
}
}
func TestValidateProjectRejectsInvalidModuleColumnExpansionFile(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules"))
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "base.json"), `{
"output": "racialtypes.2da",
"columns": ["Label"],
"rows": []
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules", "00_badcolumns.json"), `{
"columns": "ECL"
}`+"\n")
report := ValidateProject(testProject(root))
if !report.HasErrors() {
t.Fatalf("expected invalid module columns file to fail validation, got:\n%s", diagnosticsText(report.Diagnostics))
}
if !diagnosticsContain(report.Diagnostics, "columns must be a JSON array when present") {
t.Fatalf("expected columns array diagnostic, got:\n%s", diagnosticsText(report.Diagnostics))
}
}
func TestValidateProjectRejectsDuplicateEntryKeysAcrossModules(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "baseitems", "modules"))