Error on duplicate keys
This commit is contained in:
@@ -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{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user