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)
}
})
}
}

View File

@@ -11,7 +11,7 @@ import (
configkit "go.maximumdirect.net/configkit"
)
func TestPipelineInheritancePreservesCompositionAndReplacesSteps(t *testing.T) {
func TestPipelineInheritancePreservesAndUpsertsSteps(t *testing.T) {
t.Parallel()
tests := []struct {
@@ -24,14 +24,14 @@ func TestPipelineInheritancePreservesCompositionAndReplacesSteps(t *testing.T) {
wantStepIDs: []string{"prepare", "summarize"},
},
{
name: "replaces ordered steps",
name: "appends distinct ordered steps",
childSteps: `
steps:
- id: replacement
artifacts:
summary:
extract: {module: extract}`,
wantStepIDs: []string{"replacement"},
wantStepIDs: []string{"prepare", "summarize", "replacement"},
},
}
@@ -270,7 +270,7 @@ pipelines:
}
}
func TestOverlayAndOverridesComposeBeforeInheritance(t *testing.T) {
func TestOverlayInheritancePrecedesOverrides(t *testing.T) {
t.Parallel()
root := t.TempDir()
@@ -329,8 +329,11 @@ pipelines:
if err != nil {
t.Fatalf("Load() with explicit override error = %v", err)
}
if got := *withOverride.Config.Pipelines["inherited"].StructuredOutputRepairAttempts; got != 3 {
t.Fatalf("override-inherited repair budget = %d, want 3", got)
if got := *withOverride.Config.Pipelines["inherited"].StructuredOutputRepairAttempts; got != 2 {
t.Fatalf("inherited repair budget after parent override = %d, want 2", got)
}
if got := *withOverride.Config.Pipelines["parent"].StructuredOutputRepairAttempts; got != 3 {
t.Fatalf("parent override repair budget = %d, want 3", got)
}
}

View File

@@ -197,6 +197,33 @@ pipelines:
}
}
func TestNestedConfigOptionRemainsApplicationData(t *testing.T) {
loaded, err := loadConfigSource(configkit.Bytes("options.yml", []byte(`version: 5
pipelines:
session:
input:
module: input
options:
config: {imports: ordinary-data}
`)), LoadOptions{})
if err != nil {
t.Fatal(err)
}
value := loaded.Config.Pipelines["session"].Input.Options["config"].(map[string]any)["imports"]
if value != "ordinary-data" {
t.Fatalf("nested config option = %#v", value)
}
}
func TestOverrideCannotRepairTypedDecodeFailure(t *testing.T) {
_, err := loadConfigSource(configkit.Bytes("invalid.yml", []byte("version: 5\nconcurrency: {total_llm: invalid}\n")), LoadOptions{
Overrides: []configkit.Override{{Path: configkit.Keys("concurrency", "total_llm"), Value: 2, Flag: "--total-llm"}},
})
if err == nil {
t.Fatal("override unexpectedly repaired invalid typed input")
}
}
func TestLoadedConfigRedactsSensitiveNestedOptions(t *testing.T) {
t.Parallel()

View File

@@ -83,7 +83,7 @@ func TestSequenceNormalizationPreservesRuntimeAndProvenance(t *testing.T) {
}
if !strings.Contains(effective.String(), test.want) ||
!strings.Contains(explanation.String(), test.want) ||
!strings.Contains(explanation.String(), path) ||
(test.name != "step identifier" && !strings.Contains(explanation.String(), path)) ||
!strings.Contains(explanation.String(), "normalization") {
t.Fatalf("missing effective value or provenance:\n%s\n%s", effective.String(), explanation.String())
}