Validation hardening
This commit is contained in:
@@ -11242,6 +11242,66 @@ func TestBuildPackageIgnoresTemplateSourcesForFreshness(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectWarnsWhenKeyOnlyOverrideMissesCanonicalKeyByCase(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": [
|
||||
{"id": 0, "key": "baseitems:whip", "Label": "Whip", "MaxRange": "3"}
|
||||
]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "lock.json"), `{"baseitems:whip":0}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "baseitems", "modules", "ovr_baseitems_whip.json"), `{
|
||||
"overrides": [
|
||||
{"key": "baseitems:Whip", "MaxRange": "4"}
|
||||
]
|
||||
}`+"\n")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if report.HasErrors() {
|
||||
t.Fatalf("expected warning-only validation result, got errors:\n%s", diagnosticsText(report.Diagnostics))
|
||||
}
|
||||
if report.WarningCount() == 0 {
|
||||
t.Fatal("expected authoring warning for key-only override case mismatch")
|
||||
}
|
||||
text := diagnosticsText(report.Diagnostics)
|
||||
if !strings.Contains(text, `override 0 targets key "baseitems:Whip", but the live canonical key at that point is "baseitems:whip"`) {
|
||||
t.Fatalf("expected near-miss override warning, got:\n%s", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectWarnsWhenLockKeepsNormalizedEquivalentKeysAlive(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "feat"))
|
||||
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "feat", "base.json"), `{
|
||||
"output": "feat.2da",
|
||||
"columns": ["LABEL", "FEAT", "DESCRIPTION"],
|
||||
"rows": [
|
||||
{"id": 0, "key": "feat:trackless_step", "LABEL": "TRACKLESS_STEP", "FEAT": "100", "DESCRIPTION": "200"}
|
||||
]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "feat", "lock.json"), `{
|
||||
"feat:trackless_step": 0,
|
||||
"feat:tracklessstep": 1200
|
||||
}`+"\n")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if report.HasErrors() {
|
||||
t.Fatalf("expected warning-only validation result, got errors:\n%s", diagnosticsText(report.Diagnostics))
|
||||
}
|
||||
if report.WarningCount() == 0 {
|
||||
t.Fatal("expected normalized-equivalent lock warning")
|
||||
}
|
||||
text := diagnosticsText(report.Diagnostics)
|
||||
if !strings.Contains(text, `lockfile keeps multiple normalized-equivalent keys alive: feat:trackless_step, feat:tracklessstep`) {
|
||||
t.Fatalf("expected normalized-equivalent key warning, got:\n%s", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectErrorsOnTopPackageAssetCollision(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust"))
|
||||
|
||||
Reference in New Issue
Block a user