Migrate acquisition fixtures to document-root controls
This commit is contained in:
@@ -12,14 +12,14 @@ func TestBroadEmptyImportSelectionsKeepDeclaringSourceOwnership(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
directory := t.TempDir()
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `configkit:
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `config:
|
||||
imports:
|
||||
- glob: fragments/*.yml
|
||||
- path: []
|
||||
`)
|
||||
const fragments = 32
|
||||
for index := 0; index < fragments; index++ {
|
||||
writeImportFile(t, directory, fmt.Sprintf("fragments/fragment-%02d.yml", index), `configkit:
|
||||
writeImportFile(t, directory, fmt.Sprintf("fragments/fragment-%02d.yml", index), `config:
|
||||
imports:
|
||||
- path: missing.yml
|
||||
- path: []
|
||||
@@ -34,7 +34,7 @@ func TestBroadEmptyImportSelectionsKeepDeclaringSourceOwnership(t *testing.T) {
|
||||
t.Fatalf("source count = %d, want %d", len(sources), fragments+1)
|
||||
}
|
||||
for index, source := range sources {
|
||||
wantPaths := []string{"/configkit/imports/0", "/configkit/imports/1"}
|
||||
wantPaths := []string{"/config/imports/0", "/config/imports/1"}
|
||||
if index == 0 {
|
||||
wantPaths = wantPaths[1:]
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func TestOptionalEmptyImportSelectionsRemainSourceLocalAndDetached(t *testing.T)
|
||||
Value string `yaml:"value"`
|
||||
}
|
||||
directory := t.TempDir()
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `configkit:
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `config:
|
||||
imports:
|
||||
- dir: absent
|
||||
- path: missing.yml
|
||||
@@ -82,7 +82,7 @@ func TestOptionalEmptyImportSelectionsRemainSourceLocalAndDetached(t *testing.T)
|
||||
if len(sources) != 2 {
|
||||
t.Fatalf("sources = %#v", sources)
|
||||
}
|
||||
wantPaths := []string{"/configkit/imports/0", "/configkit/imports/1", "/configkit/imports/2", "/configkit/imports/3"}
|
||||
wantPaths := []string{"/config/imports/0", "/config/imports/1", "/config/imports/2", "/config/imports/3"}
|
||||
wantSelectors := []importSelector{importSelectorDirectory, importSelectorPath, importSelectorPath, importSelectorDirectory}
|
||||
evidence := sources[0].importSelections
|
||||
if len(evidence) != len(wantPaths) {
|
||||
@@ -119,7 +119,7 @@ func TestFailedLoadRetainsOnlyCompletedEmptyImportSelections(t *testing.T) {
|
||||
Value string `yaml:"value"`
|
||||
}
|
||||
directory := t.TempDir()
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `configkit:
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `config:
|
||||
imports:
|
||||
- glob: absent/*.yml
|
||||
- path: required-missing.yml
|
||||
@@ -137,11 +137,11 @@ value: main
|
||||
t.Fatalf("failed-load sources = %#v", sources)
|
||||
}
|
||||
selection := sources[0].importSelections[0]
|
||||
if selection.path.String() != "/configkit/imports/0" || selection.location.SourceID != sources[0].ID || selection.selector != importSelectorGlob {
|
||||
if selection.path.String() != "/config/imports/0" || selection.location.SourceID != sources[0].ID || selection.selector != importSelectorGlob {
|
||||
t.Fatalf("retained selection = %#v", selection)
|
||||
}
|
||||
sources[0].importSelections[0].path.segments[0].key = "changed"
|
||||
if got := loadError.Sources()[0].importSelections[0].path.String(); got != "/configkit/imports/0" {
|
||||
if got := loadError.Sources()[0].importSelections[0].path.String(); got != "/config/imports/0" {
|
||||
t.Fatalf("mutating failed-load snapshot changed retained evidence: %q", got)
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func TestImportSelectionEvidenceSurvivesCompositionUnderlaysAndResolutionEntry(t
|
||||
Overlay string `yaml:"overlay"`
|
||||
}
|
||||
directory := t.TempDir()
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `configkit:
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `config:
|
||||
imports:
|
||||
- path: helper.yml
|
||||
- path: item.yml
|
||||
@@ -169,24 +169,24 @@ func TestImportSelectionEvidenceSurvivesCompositionUnderlaysAndResolutionEntry(t
|
||||
- dir: absent-main
|
||||
value: main
|
||||
`)
|
||||
helperPath := writeImportFile(t, directory, "helper.yml", `configkit:
|
||||
helperPath := writeImportFile(t, directory, "helper.yml", `config:
|
||||
imports:
|
||||
- glob: absent-helper/*.yml
|
||||
helper: value
|
||||
`)
|
||||
itemPath := writeImportFile(t, directory, "item.yml", `configkit:
|
||||
itemPath := writeImportFile(t, directory, "item.yml", `config:
|
||||
imports:
|
||||
- path: []
|
||||
- path: item-helper.yml
|
||||
destination: [metadata]
|
||||
id: selected
|
||||
`)
|
||||
itemHelperPath := writeImportFile(t, directory, "item-helper.yml", `configkit:
|
||||
itemHelperPath := writeImportFile(t, directory, "item-helper.yml", `config:
|
||||
imports:
|
||||
- dir: absent-item-helper
|
||||
key: value
|
||||
`)
|
||||
underlayPath := writeImportFile(t, directory, "underlay.yml", `configkit:
|
||||
underlayPath := writeImportFile(t, directory, "underlay.yml", `config:
|
||||
imports:
|
||||
- path: []
|
||||
value: underlay
|
||||
@@ -216,11 +216,11 @@ value: underlay
|
||||
t.Fatalf("configuration = %#v", loaded.Config)
|
||||
}
|
||||
want := map[string]string{
|
||||
"source-1": "/configkit/imports/2",
|
||||
"source-2": "/configkit/imports/0",
|
||||
"source-3": "/configkit/imports/0",
|
||||
"source-4": "/configkit/imports/0",
|
||||
"source-5": "/configkit/imports/0",
|
||||
"source-1": "/config/imports/2",
|
||||
"source-2": "/config/imports/0",
|
||||
"source-3": "/config/imports/0",
|
||||
"source-4": "/config/imports/0",
|
||||
"source-5": "/config/imports/0",
|
||||
}
|
||||
sources := loaded.Inspection.Sources()
|
||||
if len(sources) != 6 {
|
||||
@@ -266,18 +266,18 @@ func TestFailedNestedItemLoadKeepsEvidenceWithUnresolvedDestination(t *testing.T
|
||||
Items []item `yaml:"items"`
|
||||
}
|
||||
directory := t.TempDir()
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `configkit:
|
||||
mainPath := writeImportFile(t, directory, "main.yml", `config:
|
||||
imports:
|
||||
- path: item.yml
|
||||
destination: [items]
|
||||
placement: sequence-item
|
||||
`)
|
||||
writeImportFile(t, directory, "item.yml", `configkit:
|
||||
writeImportFile(t, directory, "item.yml", `config:
|
||||
imports:
|
||||
- path: helper.yml
|
||||
destination: [metadata]
|
||||
`)
|
||||
writeImportFile(t, directory, "helper.yml", `configkit:
|
||||
writeImportFile(t, directory, "helper.yml", `config:
|
||||
imports:
|
||||
- dir: absent
|
||||
- path: missing.yml
|
||||
@@ -294,7 +294,7 @@ key: value
|
||||
continue
|
||||
}
|
||||
if !source.destinationUnresolved || source.Destination.String() != "/items" || len(source.importSelections) != 1 ||
|
||||
source.importSelections[0].path.String() != "/configkit/imports/0" || source.importSelections[0].location.SourceID != source.ID {
|
||||
source.importSelections[0].path.String() != "/config/imports/0" || source.importSelections[0].location.SourceID != source.ID {
|
||||
t.Fatalf("failed nested item source = %#v", source)
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user