Apply CLI overrides after typed decoding
This commit is contained in:
@@ -440,9 +440,11 @@ func TestOverrideAggregateLimitsFailBeforeApplication(t *testing.T) {
|
||||
t.Fatal(diagnostics)
|
||||
}
|
||||
base.inputNodes = 1
|
||||
result, sources, diagnostics := applyOverrides(base, nil, []Override{{Path: Keys("value"), Value: "x", Flag: "--value"}}, nil, importLimits{sources: 1, bytes: 1, nodes: 2})
|
||||
if result != nil || len(sources) != 1 || len(diagnostics) != 1 || diagnostics[0].Code != CodeOverrideLimitExceeded || len(base.root.Mapping) != 0 {
|
||||
t.Fatalf("bounded apply = %#v, %#v, %#v; base %#v", result, sources, diagnostics, base.root)
|
||||
_, diagnostics = preparePostStructuralOverrides(overridePreparationInput{
|
||||
root: base.root, inputBytes: base.inputBytes, inputNodes: base.inputNodes,
|
||||
}, nil, []Override{{Path: Keys("value"), Value: "x", Flag: "--value"}}, nil, importLimits{sources: 1, bytes: 1, nodes: 2})
|
||||
if len(diagnostics) != 1 || diagnostics[0].Code != CodeOverrideLimitExceeded || len(base.root.Mapping) != 0 {
|
||||
t.Fatalf("bounded preparation = %#v; base %#v", diagnostics, base.root)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +456,14 @@ func TestPreparedOverrideBatchDetachesInputsAndAllocatesSourcesInOrder(t *testin
|
||||
sources := []SourceInfo{{ID: "source-1", Label: "base", Layer: LayerBase, Kind: SourceKindMapping}}
|
||||
firstValue := map[string]any{"nested": map[string]any{"name": "original"}}
|
||||
secondValue := []any{map[string]any{"enabled": true}}
|
||||
batch, diagnostics := prepareOverrides(base, sources, []Override{
|
||||
batch, diagnostics := preparePostStructuralOverrides(overridePreparationInput{
|
||||
root: base.root, inputBytes: base.inputBytes, inputNodes: base.inputNodes,
|
||||
}, sources, []Override{
|
||||
{Path: Keys("settings", "first"), Value: firstValue, Flag: "--first"},
|
||||
{Path: Keys("settings", "second"), Value: secondValue, Flag: "--second"},
|
||||
}, nil, defaultImportLimits())
|
||||
if len(diagnostics) != 0 {
|
||||
t.Fatalf("prepare overrides: %#v", diagnostics)
|
||||
t.Fatalf("prepare post-structural overrides: %#v", diagnostics)
|
||||
}
|
||||
if len(batch.overrides) != 2 || len(batch.sources) != 3 {
|
||||
t.Fatalf("prepared counts = %d overrides, %d sources", len(batch.overrides), len(batch.sources))
|
||||
@@ -514,10 +518,9 @@ func TestPostStructuralOverridePreparationRejectsInheritanceDirectives(t *testin
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if _, diagnostics := prepareOverrides(base, nil, []Override{test.override}, nil, defaultImportLimits()); len(diagnostics) != 0 {
|
||||
t.Fatalf("legacy preparation changed before lifecycle activation: %#v", diagnostics)
|
||||
}
|
||||
_, diagnostics := preparePostStructuralOverrides(overridePreparationInputFor(base), nil, []Override{test.override}, nil, defaultImportLimits())
|
||||
_, diagnostics := preparePostStructuralOverrides(overridePreparationInput{
|
||||
root: base.root, inputBytes: base.inputBytes, inputNodes: base.inputNodes,
|
||||
}, nil, []Override{test.override}, nil, defaultImportLimits())
|
||||
if len(diagnostics) != 1 || diagnostics[0].Code != CodeOverrideDirective || diagnostics[0].Path.String() != test.path {
|
||||
t.Fatalf("post-structural diagnostics = %#v, want directive at %s", diagnostics, test.path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user