Preserve campaign defaults in materialized sessions
This commit is contained in:
@@ -241,7 +241,7 @@ inputs:
|
||||
t.Fatalf("read generated session: %v", err)
|
||||
}
|
||||
got := string(data)
|
||||
generated, err := config.LoadSession(outputPath)
|
||||
generated, err := config.LoadSessionWithOptions(outputPath, sessionInitLoadOptions(t, campaignPath))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
}
|
||||
prefix := artifacts.S3SessionPrefix("dnd", m.Campaign, m.SessionID)
|
||||
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(prefix, m.RunID), "prepare/inputs/session.yml")
|
||||
if got := string(fake.Objects[key].Data); !strings.Contains(got, "Published title") || strings.Contains(got, "imports:") || !strings.Contains(got, "speakers_file:") {
|
||||
if got := string(fake.Objects[key].Data); !strings.Contains(got, "Published title") || strings.Contains(got, "imports:") || strings.Contains(got, "speakers_file:") {
|
||||
t.Fatalf("published session = %q", got)
|
||||
}
|
||||
for _, name := range []string{"campaign.yml", "party.yml"} {
|
||||
@@ -85,7 +85,7 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
if received.Session.Title != "Published title" || received.SessionSource.S3Key != key {
|
||||
t.Fatalf("remote session = %#v, source=%#v", received.Session, received.SessionSource)
|
||||
}
|
||||
if got := received.StableInputs.SpeakersFile; got.Source != "session_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
if got := received.StableInputs.SpeakersFile; got.Source != "campaign_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
t.Fatalf("receiving campaign speakers = %#v", got)
|
||||
}
|
||||
current, err := discoverRemoteCurrentState(ctx, received, fake)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestSessionInitializationCommandKeepsYAMLIndependentOfReportFormat(t *testi
|
||||
if !report.Written || report.Remote || report.Destination != output {
|
||||
t.Fatalf("report=%#v", report)
|
||||
}
|
||||
cfg, err := config.LoadSession(output)
|
||||
cfg, err := config.LoadSessionWithOptions(output, sessionInitLoadOptions(t, campaign))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestSessionInitializationCommandRemoteRoundTrips(t *testing.T) {
|
||||
}
|
||||
key := artifacts.S3SessionConfigKey(artifacts.S3SessionPrefix("dnd", "sample-campaign", "2026-05-04"))
|
||||
data := fake.Objects[key].Data
|
||||
session, err := config.LoadSessionBytesWithOptions("remote-created", data, config.SessionLoadOptions{})
|
||||
session, err := config.LoadSessionBytesWithOptions("remote-created", data, sessionInitLoadOptions(t, campaign))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestSessionInitMaterializesLocalTemplateImports(t *testing.T) {
|
||||
if err := os.Remove(fragment); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := config.LoadSession(output)
|
||||
loaded, err := config.LoadSessionWithOptions(output, sessionInitLoadOptions(t, campaign))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func TestSessionInitPublishesStandaloneImportedTemplate(t *testing.T) {
|
||||
if err := os.Remove(fragment); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := config.LoadSessionBytesWithOptions("remote session", fake.Objects[key].Data, config.SessionLoadOptions{})
|
||||
loaded, err := config.LoadSessionBytesWithOptions("remote session", fake.Objects[key].Data, sessionInitLoadOptions(t, campaign))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestSessionInitPersistsInvocationRelativeAudio(t *testing.T) {
|
||||
if err := invokeNativeCommandWith(context.Background(), []string{"session", "init", "2026-06-07", "--config", pipeline, "--campaign-file", campaign, "--output", output, "--audio-dir", "./audio"}, &bytes.Buffer{}, executePlan, commandDependencies{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := config.LoadSession(output)
|
||||
loaded, err := config.LoadSessionWithOptions(output, sessionInitLoadOptions(t, campaign))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -73,3 +73,12 @@ func TestSessionInitPersistsInvocationRelativeAudio(t *testing.T) {
|
||||
t.Fatalf("audio = %q; want %q", loaded.Inputs.AudioDir, want)
|
||||
}
|
||||
}
|
||||
|
||||
func sessionInitLoadOptions(t *testing.T, campaignPath string) config.SessionLoadOptions {
|
||||
t.Helper()
|
||||
campaign, err := config.LoadCampaign(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return config.SessionLoadOptions{Campaign: campaign, CampaignPath: campaignPath}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user