topdata: fix global validation regressions
This commit is contained in:
@@ -461,6 +461,50 @@ func TestValidateProjectRejectsInvalidAnyPresent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectReportsUnsupportedGlobalInjectionKeysAndInvalidAnyPresent(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
writeCanonicalContractScaffold(t, root)
|
||||
writeCanonicalSpellsDataset(t, root)
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "spells", "global.json"), `{
|
||||
"injections": [
|
||||
{
|
||||
"row": {},
|
||||
"when_present": [],
|
||||
"any_present": []
|
||||
}
|
||||
]
|
||||
}`+"\n")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if !report.HasErrors() {
|
||||
t.Fatalf("expected invalid global injection to fail validation, got:\n%s", diagnosticsText(report.Diagnostics))
|
||||
}
|
||||
assertDiagnosticTextContainsAll(t, report.Diagnostics,
|
||||
`global injection 0 contains unsupported key "when_present"`,
|
||||
"any_present must contain at least one condition",
|
||||
)
|
||||
}
|
||||
|
||||
func TestValidateProjectValidatesGlobalColumnsOnce(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
writeCanonicalContractScaffold(t, root)
|
||||
writeCanonicalSpellsDataset(t, root)
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "spells", "global.json"), `{
|
||||
"columns": "ImpactScript",
|
||||
"entries": {},
|
||||
"overrides": []
|
||||
}`+"\n")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if !report.HasErrors() {
|
||||
t.Fatalf("expected invalid global columns file to fail validation, got:\n%s", diagnosticsText(report.Diagnostics))
|
||||
}
|
||||
text := diagnosticsText(report.Diagnostics)
|
||||
if got := strings.Count(text, "columns must be a JSON array when present"); got != 1 {
|
||||
t.Fatalf("expected one global columns diagnostic, got %d:\n%s", got, text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectValidatesEveryCanonicalModuleContainer(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
writeCanonicalContractScaffold(t, root)
|
||||
|
||||
Reference in New Issue
Block a user