Preserve selected collections in materialized references
This commit is contained in:
@@ -85,6 +85,24 @@ func TestReferenceCollectionResolutionAndCopy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReferenceOverrideKeepsTargetCollectionSelection(t *testing.T) {
|
||||
for _, selection := range [][]string{nil, {}, {"campaign"}} {
|
||||
target := referenceResolutionTarget{
|
||||
PipelineID: "demo", LaneID: "lane", Stage: StageExtract, Module: "extractor",
|
||||
Slots: []contracts.ReferenceSlot{{Name: "glossary"}},
|
||||
LocalReferences: map[string]ReferenceSource{"glossary": {Path: "old.yml", Collections: selection}},
|
||||
Options: ResolveOptions{ReferenceOverrides: []ReferenceBinding{{Stage: StageExtract, LaneID: "lane", SlotName: "glossary", Source: "new.yml"}}},
|
||||
}
|
||||
bindings, err := resolveReferenceTargetBindings(target)
|
||||
if err != nil || len(bindings) != 1 || bindings[0].Source != "new.yml" || (bindings[0].Collections == nil) != (selection == nil) || len(bindings[0].Collections) != len(selection) {
|
||||
t.Fatalf("override with %#v = %#v, %v", selection, bindings, err)
|
||||
}
|
||||
if len(selection) > 0 && bindings[0].Collections[0] != selection[0] {
|
||||
t.Fatalf("selection changed: %#v", bindings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeTargetReferenceSourceOwnsAndValidatesSelector(t *testing.T) {
|
||||
target := referenceResolutionTarget{PipelineID: "demo", StepID: "consumer", LaneID: "lane", Stage: StageExtract, Module: "extractor"}
|
||||
input := ReferenceSource{Artifact: &ArtifactReference{Step: " producer ", Lane: " output "}}
|
||||
|
||||
Reference in New Issue
Block a user