Added support for a minimal JSON output schema
This commit is contained in:
@@ -49,6 +49,56 @@ func TestValidateOutputFailsBeforeAssignIDs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateOutputUsesMinimalSchemaWhenConfigured(t *testing.T) {
|
||||
merged := model.MergedTranscript{
|
||||
Segments: []model.Segment{
|
||||
{
|
||||
ID: 1,
|
||||
Source: "input.json",
|
||||
SourceRef: "word-run:1:1:1",
|
||||
DerivedFrom: []string{"input.json#0"},
|
||||
Speaker: "Alice",
|
||||
Start: 1,
|
||||
End: 2,
|
||||
Text: "hello",
|
||||
Categories: []string{"backchannel"},
|
||||
OverlapGroupID: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cfg := testConfig()
|
||||
cfg.OutputSchema = config.OutputSchemaMinimal
|
||||
got, events, err := validateOutput{}.Process(context.Background(), merged, cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("validate output: %v", err)
|
||||
}
|
||||
if len(got.Segments) != 1 {
|
||||
t.Fatalf("segment count = %d, want 1", len(got.Segments))
|
||||
}
|
||||
if len(events) != 1 || !strings.Contains(events[0].Message, "validated 1 output segment(s)") {
|
||||
t.Fatalf("events = %#v", events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateOutputMinimalFailsBeforeAssignIDs(t *testing.T) {
|
||||
merged := model.MergedTranscript{
|
||||
Segments: []model.Segment{
|
||||
{Source: "input.json", Speaker: "Alice", Start: 1, End: 2, Text: "hello"},
|
||||
},
|
||||
}
|
||||
|
||||
cfg := testConfig()
|
||||
cfg.OutputSchema = config.OutputSchemaMinimal
|
||||
_, _, err := validateOutput{}.Process(context.Background(), merged, cfg)
|
||||
if err == nil {
|
||||
t.Fatal("expected validation error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "segment 0 has id 0; want 1") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testConfig() config.Config {
|
||||
return config.Config{
|
||||
InputReader: config.DefaultInputReader,
|
||||
|
||||
Reference in New Issue
Block a user