Preserve native glossary loading error classifications

This commit is contained in:
2026-11-26 21:14:32 +00:00
parent bf3184cf0a
commit 4b1812995f
5 changed files with 34 additions and 14 deletions

View File

@@ -76,15 +76,25 @@ func TestProcessRuntimeGlossaryFailures(t *testing.T) {
t.Fatal(err)
}
}
for _, name := range []string{"missing.yml", "bad.yml", "empty.yml"} {
for _, tc := range []struct {
name string
status int
diagnostic string
}{
{"missing.yml", 1, "source.missing"},
{"bad.yml", 2, "yaml.invalid"},
{"empty.yml", 2, "no glossary entries"},
} {
var stdout, stderr bytes.Buffer
output := filepath.Join(dir, "output.json")
status := Run(context.Background(), []string{"process", "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, name), "--output", output, filepath.Join(dir, "input.json")}, &stdout, &stderr)
if status != 2 {
t.Fatalf("%s: status=%d stderr=%s", name, status, stderr.String())
status := Run(context.Background(), []string{"process", "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, tc.name), "--output", output, filepath.Join(dir, "input.json")}, &stdout, &stderr)
if status != tc.status || !strings.Contains(stderr.String(), tc.diagnostic) {
t.Fatalf("%s: status=%d stderr=%s", tc.name, status, stderr.String())
}
if _, err := os.Stat(output); !os.IsNotExist(err) {
t.Fatalf("%s: output prepared: %v", name, err)
for _, name := range []string{"output.json", "errors.yml", "recoveries.yml", "report.md"} {
if _, err := os.Stat(filepath.Join(dir, name)); !os.IsNotExist(err) {
t.Fatalf("%s: output %s prepared: %v", tc.name, name, err)
}
}
}
}