Update pipeline defaults so trim is enabled when omitted
This commit is contained in:
@@ -13,6 +13,20 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
wantValidateErr string
|
||||
assert func(t *testing.T, cfg *Config)
|
||||
}{
|
||||
{
|
||||
name: "trim defaults when omitted",
|
||||
trimYAML: "",
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
assertDefaultTrimConfig(t, cfg)
|
||||
if cfg.Pipeline.Scriptorium == nil {
|
||||
t.Fatal("scriptorium config should be defaulted when trim is enabled by default")
|
||||
}
|
||||
if cfg.Pipeline.Scriptorium.Binary != DefaultScriptoriumBinary {
|
||||
t.Fatalf("scriptorium.binary = %q, want %q", cfg.Pipeline.Scriptorium.Binary, DefaultScriptoriumBinary)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid trim config",
|
||||
trimYAML: `trim:
|
||||
@@ -34,8 +48,8 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled != true {
|
||||
t.Fatalf("trim.enabled = %t, want true", cfg.Pipeline.Trim.Enabled)
|
||||
if cfg.Pipeline.Trim.Enabled == nil || !*cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want true", cfg.Pipeline.Trim.Enabled)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.ProfileID != "" {
|
||||
t.Fatalf("trim.bounds.profile_id = %q, want empty", cfg.Pipeline.Trim.Bounds.ProfileID)
|
||||
@@ -43,67 +57,25 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enabled omitted defaults disabled",
|
||||
name: "enabled omitted defaults enabled",
|
||||
trimYAML: `trim:
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatal("trim.enabled should default to false when omitted")
|
||||
}
|
||||
assertDefaultTrimConfig(t, cfg)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "missing prompt id fails when enabled",
|
||||
name: "explicit disabled remains disabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
enabled: false
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.prompt_id is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing transcript input name fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.transcript_input_name is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing bounds output path fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
output_path: transcripts/final.trimmed.json
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.bounds.output_path is required when pipeline.trim.enabled is true",
|
||||
},
|
||||
{
|
||||
name: "missing trimmed output path fails when enabled",
|
||||
trimYAML: `trim:
|
||||
enabled: true
|
||||
bounds:
|
||||
prompt_id: dnd_session.bounds
|
||||
transcript_input_name: transcript
|
||||
output_path: artifacts/session_bounds.json
|
||||
`,
|
||||
wantValidateErr: "pipeline.trim.output_path is required when pipeline.trim.enabled is true",
|
||||
assert: func(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil || cfg.Pipeline.Trim.Enabled == nil || *cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want false", cfg.Pipeline.Trim)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid timeout fails",
|
||||
@@ -185,3 +157,31 @@ func TestTrimLoadAndValidate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func assertDefaultTrimConfig(t *testing.T, cfg *Config) {
|
||||
t.Helper()
|
||||
if cfg.Pipeline.Trim == nil {
|
||||
t.Fatal("trim config should be present")
|
||||
}
|
||||
if cfg.Pipeline.Trim.Enabled == nil || !*cfg.Pipeline.Trim.Enabled {
|
||||
t.Fatalf("trim.enabled = %#v, want true", cfg.Pipeline.Trim.Enabled)
|
||||
}
|
||||
if cfg.Pipeline.Trim.OutputPath != DefaultTrimOutputPath {
|
||||
t.Fatalf("trim.output_path = %q, want %q", cfg.Pipeline.Trim.OutputPath, DefaultTrimOutputPath)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.PromptID != DefaultTrimBoundsPromptID {
|
||||
t.Fatalf("trim.bounds.prompt_id = %q, want %q", cfg.Pipeline.Trim.Bounds.PromptID, DefaultTrimBoundsPromptID)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.TranscriptInputName != DefaultTrimBoundsTranscriptInputName {
|
||||
t.Fatalf("trim.bounds.transcript_input_name = %q, want %q", cfg.Pipeline.Trim.Bounds.TranscriptInputName, DefaultTrimBoundsTranscriptInputName)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.OutputPath != DefaultTrimBoundsOutputPath {
|
||||
t.Fatalf("trim.bounds.output_path = %q, want %q", cfg.Pipeline.Trim.Bounds.OutputPath, DefaultTrimBoundsOutputPath)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Bounds.Timeout != DefaultTrimBoundsTimeout {
|
||||
t.Fatalf("trim.bounds.timeout = %q, want %q", cfg.Pipeline.Trim.Bounds.Timeout, DefaultTrimBoundsTimeout)
|
||||
}
|
||||
if cfg.Pipeline.Trim.Seriatim.Report == nil || *cfg.Pipeline.Trim.Seriatim.Report != DefaultTrimSeriatimReport {
|
||||
t.Fatalf("trim.seriatim.report = %#v, want %t", cfg.Pipeline.Trim.Seriatim.Report, DefaultTrimSeriatimReport)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user