2026-11-18 04:09:24 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestEmptyImportSourcesIncludeNestedDeclarations(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
2026-11-20 05:02:46 +00:00
|
|
|
root := writePipelineFixture(t, dir, "pipeline.yml", testTranscriptionConfig+"config:\n imports:\n - path: fragment.yml\n - path: absent-root.yml\n")
|
2026-11-18 04:09:24 +00:00
|
|
|
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)
|
|
|
|
|
}
|
2026-11-20 05:02:46 +00:00
|
|
|
count := 0
|
2026-11-18 04:09:24 +00:00
|
|
|
seen := map[string]bool{}
|
2026-11-20 05:02:46 +00:00
|
|
|
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
|
2026-11-18 04:09:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-11-20 05:02:46 +00:00
|
|
|
if count != 2 || !seen[root] || !seen[fragment] {
|
|
|
|
|
t.Fatalf("empty import count=%d sources=%v", count, seen)
|
2026-11-18 04:09:24 +00:00
|
|
|
}
|
|
|
|
|
}
|