Verify independent comparison startup

This commit is contained in:
2026-11-23 14:29:39 +00:00
parent 716869d553
commit 43a7d398b6
2 changed files with 66 additions and 0 deletions

View File

@@ -288,6 +288,12 @@ Avoid redundant tests of upstream limits, symlink policy, or exact error wording
## Stage 7 — Verify native comparisons and lazy acquisition
**Completed.** Real comparison fixtures exercise independently prepared pipeline
sources, shared-environment preservation/overwrite, and both placements of a
single pipeline-dependent party selection. Existing direct-document, override,
discovery, and lazy-command fixtures remain in place. The full application suite
passes with Go 1.27.4.
Read `configuration_comparison_test.go`, `configuration_acquisition_test.go`,
`commands_boundary_test.go`, and the native ckconfig comparison contract.

View File

@@ -143,3 +143,63 @@ func TestConfigurationComparisonKeepsCredentialValuesHidden(t *testing.T) {
}
}
}
func TestComparisonUsesConfiguredBootstrapForEachPipeline(t *testing.T) {
const name = "NARRATIO_COMPARISON_SHARED_KEY"
restoreEnvAfterTest(t, name)
root := t.TempDir()
paths := make([]string, 2)
for index, item := range []struct{ value, overwrite string }{{"left-secret", "false"}, {"right-secret", "true"}} {
dir := filepath.Join(root, []string{"first", "second"}[index])
paths[index] = filepath.Join(dir, "pipeline.yml")
mustWriteSecretFile(t, filepath.Join(dir, "secrets", name), item.value)
mustWriteTestFile(t, paths[index], "config: {secrets_dir: secrets, secrets_overwrite: "+item.overwrite+"}\nwhisperx: {transcribe_url: https://example.test}\naudita: {credentials: ["+name+"]}\n")
}
var values []string
app, err := newApplication(commandDependencies{loadPipelineSource: func(source configkit.Source, opts config.PipelineLoadOptions) (*config.PipelineConfig, error) {
cfg, err := config.LoadPipelineSourceWithOptions(source, opts)
if err == nil {
values = append(values, cfg.Audita.Credentials[0].Value())
}
return cfg, err
}}, executePlan)
if err != nil {
t.Fatal(err)
}
var output, diagnostic bytes.Buffer
result := app.Execute(context.Background(), []string{"config", "diff", "--config", paths[0], "--against-config", paths[1], "--check", "--details", "--format", "json"}, commandkit.Streams{Out: &output, Err: &diagnostic})
if result.Status != 0 || len(values) != 2 || values[0] != "left-secret" || values[1] != "right-secret" || os.Getenv(name) != "right-secret" {
t.Fatalf("status=%d values=%v diagnostic=%s", result.Status, values, diagnostic.String())
}
if strings.Contains(output.String()+diagnostic.String(), "left-secret") || strings.Contains(output.String()+diagnostic.String(), "right-secret") {
t.Fatal("comparison exposed credential values")
}
}
func TestComparisonBootstrapsOnlyTheSideNeedingPipeline(t *testing.T) {
const name = "NARRATIO_COMPARISON_PARTY_KEY"
restoreEnvAfterTest(t, name)
root := t.TempDir()
pipeline, campaign, _ := writeValidConfigFiles(t, root)
party := filepath.Join(filepath.Dir(campaign), "party.yml")
secretDir := filepath.Join(filepath.Dir(pipeline), "secrets")
mustWriteSecretFile(t, filepath.Join(secretDir, name), "pipeline-value")
configureTestSecrets(t, pipeline, secretDir)
mustWriteTestFile(t, pipeline, "config: {secrets_dir: test-secrets}\nwhisperx: {transcribe_url: https://example.test}\ncampaigns:\n root: "+filepath.Dir(filepath.Dir(campaign))+"\n default_campaign_id: sample-campaign\n")
for _, leftExact := range []bool{true, false} {
if err := os.Unsetenv(name); err != nil {
t.Fatal(err)
}
args := []string{"config", "diff", "--scope", "party", "--format", "json"}
if leftExact {
args = append(args, "--party-file", party, "--against-config", pipeline)
} else {
args = append(args, "--config", pipeline, "--against-party-file", party)
}
var output, diagnostic bytes.Buffer
result := Execute(context.Background(), args, commandkit.Streams{Out: &output, Err: &diagnostic})
if result.Status != 0 || os.Getenv(name) != "pipeline-value" || strings.Count(diagnostic.String(), `status="loaded"`) != 1 {
t.Fatalf("leftExact=%t status=%d diagnostics=%s", leftExact, result.Status, diagnostic.String())
}
}
}