Force Check Duplicates

This commit is contained in:
2026-04-04 09:34:36 +02:00
parent 38ee1e21e0
commit 9313769649
4 changed files with 52 additions and 2 deletions
+48
View File
@@ -54,6 +54,54 @@ func TestValidateProjectWarnsForCrossHAKDuplicateAssets(t *testing.T) {
}
}
func TestValidateProjectErrorsForSameHAKDuplicateAssets(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src"))
mustMkdir(t, filepath.Join(root, "assets", "core", "a"))
mustMkdir(t, filepath.Join(root, "assets", "core", "b"))
mustMkdir(t, filepath.Join(root, "build"))
mustWriteFile(t, filepath.Join(root, "nwn-tool.json"), `{
"module": {
"name": "Test Assets",
"resref": "testassets"
},
"paths": {
"source": "src",
"assets": "assets",
"build": "build"
},
"haks": [
{ "name": "core", "priority": 1, "max_bytes": 0, "split": false, "include": ["core/**"] }
]
}
`)
mustWriteFile(t, filepath.Join(root, "assets", "core", "a", "shared.mdl"), "one")
mustWriteFile(t, filepath.Join(root, "assets", "core", "b", "shared.mdl"), "two")
p, err := project.Load(root)
if err != nil {
t.Fatalf("load project: %v", err)
}
if err := p.ValidateLayout(); err != nil {
t.Fatalf("validate layout: %v", err)
}
if err := p.Scan(); err != nil {
t.Fatalf("scan: %v", err)
}
report := ValidateProject(p)
if !report.HasErrors() {
t.Fatalf("expected same-hak duplicate to be an error, got %#v", report.Diagnostics)
}
if report.ErrorCount() != 1 {
t.Fatalf("expected 1 error, got %d (%#v)", report.ErrorCount(), report.Diagnostics)
}
if report.WarningCount() != 0 {
t.Fatalf("expected no warnings, got %d (%#v)", report.WarningCount(), report.Diagnostics)
}
}
func TestValidateProjectWarnsForUppercaseResourceNames(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src", "blueprints", "items"))