Finish native completion and retire legacy command machinery
This commit is contained in:
@@ -76,22 +76,23 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
}
|
||||
setSessionConfigSearchPaths(t, []string{sessionPath})
|
||||
deps, _ := remoteSessionLoaderDependencies(fake)
|
||||
loaded, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
|
||||
loaded := newConfigurationAcquisition(configurationSelection{Config: suppliedSelection(pipelinePath), CampaignFile: suppliedSelection(campaignPath), Session: suppliedSelection(m.SessionID)}, deps)
|
||||
received, err := loaded.Domain(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = loaded.Close() }()
|
||||
if loaded.Config.Session.Title != "Published title" || loaded.Config.SessionSource.S3Key != key {
|
||||
t.Fatalf("remote session = %#v, source=%#v", loaded.Config.Session, loaded.Config.SessionSource)
|
||||
if received.Session.Title != "Published title" || received.SessionSource.S3Key != key {
|
||||
t.Fatalf("remote session = %#v, source=%#v", received.Session, received.SessionSource)
|
||||
}
|
||||
if got := loaded.Config.StableInputs.SpeakersFile; got.Source != "session_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
if got := received.StableInputs.SpeakersFile; got.Source != "session_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
t.Fatalf("receiving campaign speakers = %#v", got)
|
||||
}
|
||||
current, err := discoverRemoteCurrentState(ctx, loaded.Config, fake)
|
||||
current, err := discoverRemoteCurrentState(ctx, received, fake)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
plan, err := buildRestorePlan(ctx, loaded.Config, current, fake, RestorePlanOptions{Force: true})
|
||||
plan, err := buildRestorePlan(ctx, received, current, fake, RestorePlanOptions{Force: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -113,7 +114,7 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
}
|
||||
}
|
||||
var output strings.Builder
|
||||
if err := restoreWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--force"}, &output, deps); err != nil {
|
||||
if err := invokeNativeCommandWith(ctx, []string{"session", "restore", m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--force"}, &output, executePlan, deps); err != nil {
|
||||
t.Fatalf("restore: %v", err)
|
||||
}
|
||||
restored, err := os.ReadFile(filepath.Join(paths.InputsDir, "session.yml"))
|
||||
@@ -121,21 +122,22 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
t.Fatalf("restored session = %q, %v", restored, err)
|
||||
}
|
||||
committedBytes := string(fake.Objects[key].Data)
|
||||
if err := sessionInitWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--remote", "--force", "--title", "Updated title", "--audio-s3-prefix", "replacement/"}, &output, deps); err != nil {
|
||||
if err := invokeNativeCommandWith(ctx, []string{"session", "init", m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--remote", "--force", "--title", "Updated title", "--audio-s3-prefix", "replacement/"}, &output, executePlan, deps); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
updated, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
|
||||
updated := newConfigurationAcquisition(configurationSelection{Config: suppliedSelection(pipelinePath), CampaignFile: suppliedSelection(campaignPath), Session: suppliedSelection(m.SessionID)}, deps)
|
||||
authored, err := updated.Domain(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = updated.Close() }()
|
||||
if updated.Config.Session.Title != "Updated title" || updated.Config.Session.Inputs.AudioS3 == nil || updated.Config.Session.Inputs.AudioS3.Prefix != "replacement/" {
|
||||
t.Fatalf("remote edit ignored: %#v", updated.Config.Session)
|
||||
if authored.Session.Title != "Updated title" || authored.Session.Inputs.AudioS3 == nil || authored.Session.Inputs.AudioS3.Prefix != "replacement/" {
|
||||
t.Fatalf("remote edit ignored: %#v", authored.Session)
|
||||
}
|
||||
if string(fake.Objects[key].Data) != committedBytes {
|
||||
t.Fatal("authoring update changed committed input")
|
||||
}
|
||||
if _, err := discoverRemoteCurrentState(ctx, updated.Config, fake); err != nil {
|
||||
if _, err := discoverRemoteCurrentState(ctx, authored, fake); err != nil {
|
||||
t.Fatalf("committed state after authoring update: %v", err)
|
||||
}
|
||||
// Remove the authored override to exercise committed-snapshot integrity below.
|
||||
@@ -147,7 +149,9 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
modified := append([]byte(nil), object.Data...)
|
||||
modified[0] ^= 1
|
||||
fake.SeedObject(storage.FakeObject{Key: key, Data: modified, ETag: object.ETag})
|
||||
if _, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps); err == nil || !strings.Contains(err.Error(), "committed checksum") {
|
||||
tampered := newConfigurationAcquisition(configurationSelection{Config: suppliedSelection(pipelinePath), CampaignFile: suppliedSelection(campaignPath), Session: suppliedSelection(m.SessionID)}, deps)
|
||||
defer func() { _ = tampered.Close() }()
|
||||
if _, err := tampered.Domain(ctx); err == nil || !strings.Contains(err.Error(), "committed checksum") {
|
||||
t.Fatalf("changed remote session error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user