Add output validation against a defined JSON schema
This commit is contained in:
@@ -102,6 +102,9 @@ func TestMergeWritesMergedOutputAndReport(t *testing.T) {
|
||||
if !equalStrings(gotModules, wantModules) {
|
||||
t.Fatalf("report event order mismatch:\ngot %v\nwant %v", gotModules, wantModules)
|
||||
}
|
||||
if !hasReportEvent(rpt, "postprocessing", "validate-output", "validated 3 output segment(s)") {
|
||||
t.Fatal("expected validate-output report event")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeTieBreakOrder(t *testing.T) {
|
||||
@@ -153,6 +156,28 @@ func TestMergeTieBreakOrder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeValidateOutputBeforeAssignIDsFails(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
input := writeJSONFile(t, dir, "input.json", `{
|
||||
"segments": [
|
||||
{"start": 1, "end": 2, "text": "hello"}
|
||||
]
|
||||
}`)
|
||||
output := filepath.Join(dir, "merged.json")
|
||||
|
||||
err := executeMerge(
|
||||
"--input-file", input,
|
||||
"--output-file", output,
|
||||
"--postprocessing-modules", "validate-output,assign-ids",
|
||||
)
|
||||
if err == nil {
|
||||
t.Fatal("expected validation error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "validate-output: segment 0 has id 0; want 1") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeDetectsOverlapGroups(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
inputA := writeJSONFile(t, dir, "a.json", `{
|
||||
|
||||
Reference in New Issue
Block a user