Verify record inheritance through pipeline resolution
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
@@ -179,7 +180,7 @@ pipelines:
|
||||
}
|
||||
}
|
||||
|
||||
func TestIdentifiedStepRecordInheritance(t *testing.T) {
|
||||
func TestIdentifiedStepInheritanceDoesNotCreateTemplateSteps(t *testing.T) {
|
||||
main := filepath.Join(t.TempDir(), "main.yml")
|
||||
if err := os.WriteFile(main, []byte(`version: 5
|
||||
pipelines:
|
||||
@@ -205,6 +206,52 @@ pipelines:
|
||||
if err := loaded.Config.Validate(); err != nil {
|
||||
t.Fatalf("validate inherited steps: %v", err)
|
||||
}
|
||||
if _, err := loaded.Config.Resolve(ResolveInput{PipelineID: "session", Catalog: effectiveCatalog(t)}); err == nil || !strings.Contains(err.Error(), `step "parent" must declare at least one artifact lane`) {
|
||||
t.Fatalf("expected non-executable parent rejection, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIdentifiedValidatorRecordInheritanceResolves(t *testing.T) {
|
||||
main := filepath.Join(t.TempDir(), "main.yml")
|
||||
if err := os.WriteFile(main, []byte(`version: 5
|
||||
config:
|
||||
sequences:
|
||||
- destination: [pipelines, session, artifacts, result, extract, validators]
|
||||
key: module
|
||||
pipelines:
|
||||
session:
|
||||
input: {module: input}
|
||||
artifacts:
|
||||
result:
|
||||
extract:
|
||||
module: extract
|
||||
validators:
|
||||
- module: configured-a
|
||||
options: {nested: {inherited: true}}
|
||||
- module: configured-b
|
||||
extends: {module: configured-a}
|
||||
`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := Load(main, LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
effective, err := loaded.Config.Resolve(ResolveInput{PipelineID: "session", Catalog: effectiveCatalog(t)})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, chain := range effective.ResolvedPipeline.ValidatorChains {
|
||||
for _, validator := range chain.Validators {
|
||||
if validator.Binding.Module == "configured-b" {
|
||||
if nested, ok := validator.Binding.Options["nested"].(map[string]any); !ok || nested["inherited"] != true {
|
||||
t.Fatalf("inherited options = %#v", validator.Binding.Options)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Fatal("inheriting validator missing from resolved pipeline")
|
||||
}
|
||||
|
||||
func TestEmptyStepOperationsAndOptionalImports(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user