Preserve null collections in effective YAML
This commit is contained in:
@@ -207,6 +207,56 @@ scriptorium:
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigShowPreservesNullAndEmptyCollections(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pipelinePath := filepath.Join(dir, "pipeline.yml")
|
||||
mustWriteTestFile(t, pipelinePath, `workspace:
|
||||
root: /tmp/narratio-work
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.example.test/transcribe
|
||||
audita:
|
||||
modules: null
|
||||
scriptorium:
|
||||
artifacts: null
|
||||
`)
|
||||
mustWriteTestFile(t, filepath.Join(dir, "profiles", "empty.yml"), `audita:
|
||||
modules: []
|
||||
scriptorium:
|
||||
artifacts: {}
|
||||
`)
|
||||
|
||||
var base, empty bytes.Buffer
|
||||
if err := ConfigShow(context.Background(), []string{"--config", pipelinePath}, &base); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ConfigShow(context.Background(), []string{"--config", pipelinePath, "--profile", "empty"}, &empty); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []string{"modules: null\n", "artifacts: null\n"} {
|
||||
if !strings.Contains(base.String(), want) {
|
||||
t.Fatalf("base show output missing %q:\n%s", want, base.String())
|
||||
}
|
||||
}
|
||||
for _, want := range []string{"modules: []\n", "artifacts: {}\n"} {
|
||||
if !strings.Contains(empty.String(), want) {
|
||||
t.Fatalf("empty-profile show output missing %q:\n%s", want, empty.String())
|
||||
}
|
||||
}
|
||||
|
||||
var diff bytes.Buffer
|
||||
if err := ConfigDiff(context.Background(), []string{"default", "empty", "--config", pipelinePath}, &diff); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"changed\taudita.modules\tnull\t[]\n",
|
||||
"changed\tscriptorium.artifacts\tnull\t{}\n",
|
||||
} {
|
||||
if !strings.Contains(diff.String(), want) {
|
||||
t.Fatalf("diff output missing %q:\n%s", want, diff.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigDiffComparesExpandedFamiliesAndPublishRules(t *testing.T) {
|
||||
pipelinePath, campaignPath := writeInspectionFamilyConfig(t)
|
||||
writeInspectionProfiles(t, pipelinePath, `scriptorium:
|
||||
|
||||
Reference in New Issue
Block a user