Report effective resource contributors without superseded definitions
This commit is contained in:
42
internal/config/effective_resource_sources_test.go
Normal file
42
internal/config/effective_resource_sources_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEffectiveResourceSourcesExcludeSupersededDefinitions(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: shared.yml\nnotarius:\n extends: audita\n")
|
||||
writePipelineFixture(t, dir, "shared.yml", "audita: {config_path: old.yml}\n")
|
||||
overlayPath := writePipelineFixture(t, dir, "overlays/testing.yml", "audita: {config_path: replacement.yml}\n")
|
||||
overlay := "testing"
|
||||
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Overlay: &overlay})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
records, err := EffectivePipelineSources(cfg, ResolvedParty{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{"audita.config_path", "notarius.config_path"} {
|
||||
foundOverlay, foundResolution := false, false
|
||||
for _, record := range records {
|
||||
if record.Path != path {
|
||||
continue
|
||||
}
|
||||
if record.Role == "overlay" && record.Source == overlayPath {
|
||||
foundOverlay = true
|
||||
}
|
||||
if record.Role == "resolution" {
|
||||
foundResolution = true
|
||||
}
|
||||
if record.Source == filepath.Join(dir, "shared.yml") {
|
||||
t.Fatalf("superseded source for %s: %#v", path, record)
|
||||
}
|
||||
}
|
||||
if !foundOverlay || !foundResolution {
|
||||
t.Fatalf("missing effective evidence for %s: %#v", path, records)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user