Complete session defaults within the ConfigKit lifecycle

This commit is contained in:
2026-11-20 04:24:20 +00:00
parent 16a4f7ee12
commit c3e6245416
17 changed files with 315 additions and 154 deletions

View File

@@ -116,11 +116,7 @@ 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
`
sessionYAML := "session_id: 2026-05-03\n" + standaloneSessionFields
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
t.Fatalf("write session.yml: %v", err)
}
@@ -196,7 +192,7 @@ inputs:
}
func TestLoadSessionBytesWithOptionsStrictDecode(t *testing.T) {
cfg, err := LoadSessionBytesWithOptions("s3://bucket/session.yml", []byte("session_id: 2026-05-03\n"), SessionLoadOptions{})
cfg, err := LoadSessionBytesWithOptions("s3://bucket/session.yml", []byte("session_id: 2026-05-03\n"+standaloneSessionFields), SessionLoadOptions{})
if err != nil {
t.Fatalf("LoadSessionBytesWithOptions() error = %v", err)
}
@@ -214,7 +210,7 @@ func TestLoadSessionBytesWithOptionsStrictDecode(t *testing.T) {
}
func TestLoadSessionBytesWithOptionsMismatchFails(t *testing.T) {
_, err := LoadSessionBytesWithOptions("s3://bucket/session.yml", []byte("session_id: 2026-05-03\n"), SessionLoadOptions{SessionID: "2026-04-04"})
_, err := LoadSessionBytesWithOptions("s3://bucket/session.yml", []byte("session_id: 2026-05-03\n"+standaloneSessionFields), SessionLoadOptions{SessionID: "2026-04-04"})
if err == nil {
t.Fatal("expected mismatch error, got nil")
}
@@ -226,7 +222,7 @@ func TestLoadSessionBytesWithOptionsMismatchFails(t *testing.T) {
func TestLoadSessionBytesWithOptionsRequiresExpectedPreviousSession(t *testing.T) {
_, err := LoadSessionBytesWithOptions(
"s3://bucket/session.yml",
[]byte("session_id: 2026-05-03\n"),
[]byte("session_id: 2026-05-03\n"+standaloneSessionFields),
SessionLoadOptions{PreviousSessionID: "2026-04-26"},
)
if err == nil || !strings.Contains(err.Error(), "previous_session_id is required") {
@@ -248,3 +244,13 @@ func assertConcreteSessionTemplateError(t *testing.T, err error, vars ...string)
}
}
}
// Minimal concrete session fields for tests that exercise source acquisition or
// identity assertions independently of campaign defaulting.
const standaloneSessionFields = `campaign: sample-campaign
inputs:
audio_dir: audio
speakers_file: speakers.yml
autocorrect_file: autocorrect.yml
glossary_file: glossary.yml
`