Harden configuration validation
This commit is contained in:
@@ -121,6 +121,24 @@ inputs:
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSessionWithOptionsRequiresExpectedPreviousSession(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
sessionPath := filepath.Join(dir, "session.yml")
|
||||
sessionYAML := `session_id: 2026-05-03
|
||||
campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
t.Fatalf("write session.yml: %v", err)
|
||||
}
|
||||
|
||||
_, err := LoadSessionWithOptions(sessionPath, SessionLoadOptions{PreviousSessionID: "2026-04-26"})
|
||||
if err == nil || !strings.Contains(err.Error(), "previous_session_id is required") {
|
||||
t.Fatalf("LoadSessionWithOptions() error = %v, want missing previous-session expectation error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSessionWithOptionsUnknownFieldStillRejected(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
sessionPath := filepath.Join(dir, "session.yml")
|
||||
@@ -217,6 +235,17 @@ func TestLoadSessionBytesWithOptionsMismatchFails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSessionBytesWithOptionsRequiresExpectedPreviousSession(t *testing.T) {
|
||||
_, err := LoadSessionBytesWithOptions(
|
||||
"s3://bucket/session.yml",
|
||||
[]byte("session_id: 2026-05-03\n"),
|
||||
SessionLoadOptions{PreviousSessionID: "2026-04-26"},
|
||||
)
|
||||
if err == nil || !strings.Contains(err.Error(), "previous_session_id is required") {
|
||||
t.Fatalf("LoadSessionBytesWithOptions() error = %v, want missing previous-session expectation error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func assertConcreteSessionTemplateError(t *testing.T, err error, vars ...string) {
|
||||
t.Helper()
|
||||
if !strings.Contains(err.Error(), "session.yml must be concrete") {
|
||||
|
||||
Reference in New Issue
Block a user