Expose native configuration inspection scopes

This commit is contained in:
2026-11-20 05:02:46 +00:00
parent 1e67c429b7
commit c3c6849bed
31 changed files with 412 additions and 1567 deletions

View File

@@ -4,24 +4,24 @@ 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")
root := writePipelineFixture(t, dir, "pipeline.yml", testTranscriptionConfig+"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)
}
count := 0
seen := map[string]bool{}
for _, selection := range selections {
if selection.Selector != "path" || selection.Path == "" || selection.Line == 0 {
t.Fatalf("incomplete evidence: %#v", selection)
for _, source := range cfg.ConfigKitResult().Sources() {
for _, selection := range source.EmptyImportSelections {
count++
if selection.Selector != "path" || selection.Path.String() == "" || selection.Location.Line == 0 {
t.Fatalf("incomplete evidence: %#v", selection)
}
seen[source.Path] = true
}
seen[selection.Source] = true
}
if !seen[root] || !seen[fragment] {
t.Fatalf("source evidence: %#v", selections)
if count != 2 || !seen[root] || !seen[fragment] {
t.Fatalf("empty import count=%d sources=%v", count, seen)
}
}