Migrate structural and inspection fixtures
This commit is contained in:
@@ -8,6 +8,27 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestControlEvidenceAndApplicationValuesSharePathText(t *testing.T) {
|
||||
directory := t.TempDir()
|
||||
main := writeImportFile(t, directory, "main.yml", "config: {imports: [{path: missing.yml}, {path: data.yml, destination: [config]}]}\n")
|
||||
writeImportFile(t, directory, "data.yml", "imports: [ordinary]\n")
|
||||
loaded, err := testLoad[map[string]any](File(main), Options[map[string]any]{Imports: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sources := loaded.Sources()
|
||||
if len(sources) != 2 || len(sources[0].importSelections) != 1 || sources[0].importSelections[0].path.String() != "/config/imports/0" || sources[0].importSelections[0].location.SourceID != sources[0].ID {
|
||||
t.Fatalf("source control evidence = %#v", sources)
|
||||
}
|
||||
info, ok := loaded.Metadata().Lookup(Keys("config", "imports").Index(0))
|
||||
if !ok || len(info.Origin.Locations) == 0 || info.Origin.Locations[0].SourceID != sources[1].ID {
|
||||
t.Fatalf("application value attribution = %#v, %t", info, ok)
|
||||
}
|
||||
if got := loaded.Config["config"].(map[string]any)["imports"].([]any)[0]; got != "ordinary" {
|
||||
t.Fatalf("application value = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBroadEmptyImportSelectionsKeepDeclaringSourceOwnership(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user