Materialize extraction reference files
This commit is contained in:
@@ -559,6 +559,60 @@ func TestRunPassesModuleBindingConfigToStageRequests(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPassesLaneReferencesToExtractorRequests(t *testing.T) {
|
||||
modules := defaultRunnerModules()
|
||||
pipeline := resolvedPipeline()
|
||||
pipeline.ArtifactLanes[0].ReferenceSet = contracts.ReferenceSet{
|
||||
Slots: map[string]contracts.ResolvedReferenceSlot{
|
||||
"roster": {
|
||||
Slot: contracts.ReferenceSlot{Name: "roster"},
|
||||
Items: []contracts.ReferenceItem{
|
||||
{
|
||||
SlotName: "roster",
|
||||
MediaType: "text/plain; charset=utf-8",
|
||||
Content: []byte("reference text"),
|
||||
Digest: "sha256:test",
|
||||
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///tmp/reference.txt"},
|
||||
SizeBytes: int64(len("reference text")),
|
||||
BindingSource: contracts.ReferenceBindingSourceConfig,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_, err := New(newRunnerRegistries(t, modules)).Run(context.Background(), RunInput{Pipeline: pipeline})
|
||||
if err != nil {
|
||||
t.Fatalf("Run() error = %v, want nil", err)
|
||||
}
|
||||
|
||||
req := modules.extractors["extract-alpha"].requests[0]
|
||||
item := req.References.Slots["roster"].Items[0]
|
||||
if string(item.Content) != "reference text" {
|
||||
t.Fatalf("reference content = %q, want reference text", item.Content)
|
||||
}
|
||||
item.Content[0] = 'R'
|
||||
if got := string(pipeline.ArtifactLanes[0].ReferenceSet.Slots["roster"].Items[0].Content); got != "reference text" {
|
||||
t.Fatalf("runner mutated reference set content = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunIncludesInputWarnings(t *testing.T) {
|
||||
modules := defaultRunnerModules()
|
||||
warning := contracts.Warning{Scope: "reference", ReasonCode: "empty_reference", Message: "empty reference"}
|
||||
|
||||
output, err := New(newRunnerRegistries(t, modules)).Run(context.Background(), RunInput{
|
||||
Pipeline: resolvedPipeline(),
|
||||
Warnings: []contracts.Warning{warning},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run() error = %v, want nil", err)
|
||||
}
|
||||
if len(output.Warnings) != 1 || output.Warnings[0] != warning {
|
||||
t.Fatalf("warnings = %#v, want input warning", output.Warnings)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunRecordsTopLevelModuleMetadataForSingletonModules(t *testing.T) {
|
||||
modules := defaultRunnerModules()
|
||||
modules.input.manifestMetadata = map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user