Error on duplicate keys

This commit is contained in:
2026-05-15 23:02:33 +02:00
parent 505afb5ac5
commit 28bea40038
2 changed files with 92 additions and 0 deletions
+33
View File
@@ -134,6 +134,39 @@ func TestValidateProjectRejectsDuplicateJSONKeys(t *testing.T) {
}
}
func TestValidateProjectRejectsDuplicateEntryKeysAcrossModules(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "baseitems", "modules"))
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "base.json"), `{
"output": "baseitems.2da",
"columns": ["Label", "MaxRange"],
"rows": []
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "lock.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "modules", "10_add_sign.json"), `{
"entries": {
"baseitems:holdable_sign": {"Label": "Holdable Sign", "MaxRange": "100"}
}
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "modules", "20_add_sign_again.json"), `{
"entries": {
"baseitems:holdable_sign": {"Label": "Duplicate Sign", "MaxRange": "200"}
}
}`+"\n")
report := ValidateProject(testProject(root))
if !report.HasErrors() {
t.Fatal("expected duplicate entry key validation error")
}
text := diagnosticsText(report.Diagnostics)
if !strings.Contains(text, `duplicate entries key "baseitems:holdable_sign"`) ||
!strings.Contains(text, "10_add_sign.json") ||
!strings.Contains(text, "20_add_sign_again.json") {
t.Fatalf("expected duplicate entry key diagnostic with both module paths, got:\n%s", text)
}
}
func TestResolvedTableRegistryRegistersConsistentTables(t *testing.T) {
collected := []nativeCollectedDataset{
{