Update configuration fixtures for native composition

This commit is contained in:
2026-11-17 20:50:07 +00:00
parent 61ceab786c
commit 716bc62991
7 changed files with 94 additions and 9 deletions

View File

@@ -178,3 +178,53 @@ pipelines:
t.Fatalf("resolve composed pipeline: %v", err)
}
}
func TestEmptyStepOperationsAndOptionalImports(t *testing.T) {
root := t.TempDir()
main := filepath.Join(root, "main.yml")
if err := os.WriteFile(main, []byte(`version: 5
config:
imports:
- path: absent.yml
pipelines:
session:
input: {module: input}
steps:
- id: first
artifacts: {result: {extract: {module: extract}}}
`), 0600); err != nil {
t.Fatal(err)
}
for _, tc := range []struct {
mode, value string
wantError bool
}{
{"append", "[]", false}, {"upsert", "[]", false}, {"replace", "[]", true}, {"replace", "null", true},
} {
t.Run(tc.mode+tc.value, func(t *testing.T) {
name := tc.mode + map[string]string{"[]": "empty", "null": "null"}[tc.value]
path := filepath.Join(root, "overlays", name+".yml")
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
}
data := "config:\n sequences:\n - destination: [pipelines, session, steps]\n mode: " + tc.mode + "\npipelines:\n session: {steps: " + tc.value + "}\n"
if err := os.WriteFile(path, []byte(data), 0600); err != nil {
t.Fatal(err)
}
loaded, err := Load(main, LoadOptions{Overlay: name})
if tc.wantError {
if err == nil {
t.Fatal("invalid steps were accepted")
}
return
}
if err != nil {
t.Fatal(err)
}
steps := loaded.Config.Pipelines["session"].Steps
if len(steps) != 1 || steps[0].ID != "first" {
t.Fatalf("steps = %#v", steps)
}
})
}
}