Reuse native source records and catalog source indexes
This commit is contained in:
27
internal/config/empty_import_sources_test.go
Normal file
27
internal/config/empty_import_sources_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEmptyImportSourcesIncludeNestedDeclarations(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: fragment.yml\n - path: absent-root.yml\n")
|
||||
fragment := writePipelineFixture(t, dir, "fragment.yml", "config:\n imports:\n - path: absent-child.yml\n")
|
||||
cfg, err := LoadPipeline(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
selections := EffectiveEmptyImports(cfg, nil)
|
||||
if len(selections) != 2 {
|
||||
t.Fatalf("empty selections: %#v", selections)
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, selection := range selections {
|
||||
if selection.Selector != "path" || selection.Path == "" || selection.Line == 0 {
|
||||
t.Fatalf("incomplete evidence: %#v", selection)
|
||||
}
|
||||
seen[selection.Source] = true
|
||||
}
|
||||
if !seen[root] || !seen[fragment] {
|
||||
t.Fatalf("source evidence: %#v", selections)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user