Preserve source paths during field normalization
This commit is contained in:
@@ -27,7 +27,7 @@ func TestDocumentPathsUseDeclaringFilesAcrossImports(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(main, []byte(`version: 5
|
||||
configkit:
|
||||
config:
|
||||
imports:
|
||||
- path: fragments/pipelines.yml
|
||||
output: {directory: ./output}
|
||||
@@ -56,6 +56,47 @@ pipelines:
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiscoveredMainAndStepReferenceNormalization(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
fragmentDir := filepath.Join(root, "fragments")
|
||||
if err := os.Mkdir(fragmentDir, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main := filepath.Join(root, "notarius.yml")
|
||||
fragment := filepath.Join(fragmentDir, "pipeline.yml")
|
||||
if err := os.WriteFile(main, []byte("version: 5\nconfig:\n imports:\n - path: fragments/pipeline.yml\n required: true\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(fragment, []byte(`pipelines:
|
||||
session:
|
||||
input: {module: input}
|
||||
steps:
|
||||
- id: " first "
|
||||
references:
|
||||
" source ": {path: " ./source.txt "}
|
||||
artifacts:
|
||||
result:
|
||||
extract: {module: " extract "}
|
||||
`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := LoadSource(configkit.SearchConfig("", configkit.SearchPaths(main), configkit.SearchOptions{Required: true}), LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.MainSourcePath() != main || loaded.Config.Output.Directory != filepath.Join(root, "notarius-output") {
|
||||
t.Fatalf("discovered main or default directory: %q, %q", loaded.MainSourcePath(), loaded.Config.Output.Directory)
|
||||
}
|
||||
step := loaded.Config.Pipelines["session"].Steps[0]
|
||||
if step.ID != "first" || step.Artifacts["result"].Extract.Module != "extract" || step.References["source"].Path != filepath.Join(fragmentDir, "source.txt") {
|
||||
t.Fatalf("normalized step = %#v", step)
|
||||
}
|
||||
history := loaded.result.Metadata().History(configkit.Keys("pipelines", "session", "steps").Index(0).Key("artifacts").Key("result").Key("extract").Key("module"))
|
||||
if len(history) < 2 || history[len(history)-1].Origin.Operation != configkit.ChangeNormalization {
|
||||
t.Fatalf("module leaf history = %#v", history)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentPathsUseInvocationDirectoryForOverrides(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user