Migrate acquisition fixtures to document-root controls
This commit is contained in:
@@ -21,18 +21,18 @@ func testGroupedLoad[T any](request loadRequest[T]) (*testResult[T], error) {
|
||||
|
||||
func TestUnderlayGroupSchedulesInterleavedImportBranches(t *testing.T) {
|
||||
directory := t.TempDir()
|
||||
zRoot := writeImportFile(t, directory, "z-root.yml", `configkit:
|
||||
zRoot := writeImportFile(t, directory, "z-root.yml", `config:
|
||||
imports:
|
||||
- path: d-parent.yml
|
||||
items: [{id: z}]
|
||||
`)
|
||||
dParent := writeImportFile(t, directory, "d-parent.yml", `configkit:
|
||||
dParent := writeImportFile(t, directory, "d-parent.yml", `config:
|
||||
imports:
|
||||
- path: a-dependency.yml
|
||||
items: [{id: d}]
|
||||
`)
|
||||
aDependency := writeImportFile(t, directory, "a-dependency.yml", "items: [{id: a}]\n")
|
||||
bRoot := writeImportFile(t, directory, "b-root.yml", `configkit:
|
||||
bRoot := writeImportFile(t, directory, "b-root.yml", `config:
|
||||
imports:
|
||||
- path: c-helper.yml
|
||||
items: [{id: b}]
|
||||
@@ -75,7 +75,7 @@ items: [{id: b}]
|
||||
|
||||
func TestUnderlayGroupAcquisitionRetainsScopesUntilComposition(t *testing.T) {
|
||||
filesystem := NewFilesystem("handoff", fstest.MapFS{
|
||||
"main.yml": &fstest.MapFile{Data: []byte("configkit: {imports: [{path: child.yml}]}\nmain: retained\n")},
|
||||
"main.yml": &fstest.MapFile{Data: []byte("config: {imports: [{path: child.yml}]}\nmain: retained\n")},
|
||||
"child.yml": &fstest.MapFile{Data: []byte("child: retained\n")},
|
||||
})
|
||||
accounting := &importAccounting{}
|
||||
@@ -91,7 +91,7 @@ func TestUnderlayGroupAcquisitionRetainsScopesUntilComposition(t *testing.T) {
|
||||
if len(acquired.sources) != 2 || acquired.sources[0].UnderlayIndex != 2 || acquired.sources[1].ID != "source-2" {
|
||||
t.Fatalf("acquired source evidence = %#v", acquired.sources)
|
||||
}
|
||||
if acquired.inputBytes != int64(len("configkit: {imports: [{path: child.yml}]}\nmain: retained\n")+len("child: retained\n")) {
|
||||
if acquired.inputBytes != int64(len("config: {imports: [{path: child.yml}]}\nmain: retained\n")+len("child: retained\n")) {
|
||||
t.Fatalf("group input byte accounting = %d", acquired.inputBytes)
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func TestUnderlayItemConflictUsesScheduledGroupIndex(t *testing.T) {
|
||||
|
||||
func TestUnderlayItemHelperConflictUsesScheduledGroupIndex(t *testing.T) {
|
||||
directory := t.TempDir()
|
||||
zBad := writeImportFile(t, directory, "z-bad.yml", "configkit: {imports: [{path: helper.yml}]}\nid: duplicate\n")
|
||||
zBad := writeImportFile(t, directory, "z-bad.yml", "config: {imports: [{path: helper.yml}]}\nid: duplicate\n")
|
||||
helper := writeImportFile(t, directory, "helper.yml", "id: duplicate\n")
|
||||
aGood := writeImportFile(t, directory, "a-good.yml", "id: good\n")
|
||||
request := loadRequest[map[string]any]{
|
||||
@@ -246,7 +246,7 @@ func TestUnderlayItemHelperConflictUsesScheduledGroupIndex(t *testing.T) {
|
||||
|
||||
func TestGroupedLoadPrecedenceSourceOrderAndSingleLifecycle(t *testing.T) {
|
||||
filesystem := NewFilesystem("bundle", fstest.MapFS{
|
||||
"main.yml": &fstest.MapFile{Data: []byte("configkit: {imports: [{path: imported.yml}]}\nversion: v1\nport: 5\nsettings: {shared: main}\n")},
|
||||
"main.yml": &fstest.MapFile{Data: []byte("config: {imports: [{path: imported.yml}]}\nversion: v1\nport: 5\nsettings: {shared: main}\n")},
|
||||
"imported.yml": &fstest.MapFile{Data: []byte("settings: {imported: included}\n")},
|
||||
"overlays/test.yml": &fstest.MapFile{Data: []byte("settings: {shared: overlay}\n")},
|
||||
})
|
||||
@@ -340,7 +340,7 @@ func TestGroupedLoadAbsentMainAndVersionProtection(t *testing.T) {
|
||||
t.Fatalf("underlay version code = %s", got)
|
||||
}
|
||||
filesystem := NewFilesystem("bundle", fstest.MapFS{
|
||||
"main.yml": &fstest.MapFile{Data: []byte("configkit: {imports: [{path: fragment.yml}]}\n")},
|
||||
"main.yml": &fstest.MapFile{Data: []byte("config: {imports: [{path: fragment.yml}]}\n")},
|
||||
"fragment.yml": &fstest.MapFile{Data: []byte("version: forbidden\n")},
|
||||
})
|
||||
request.underlays[1].inputs[0] = loadInput{source: filesystem.File("main.yml"), imports: true}
|
||||
@@ -359,7 +359,7 @@ func TestGroupedLoadAbsentMainAndVersionProtection(t *testing.T) {
|
||||
func TestLayeredCollectionPolicyFlowsBetweenTiers(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
policyOnly := Bytes("lower-policy", []byte("configkit:\n sequences:\n - destination: [items]\n key: id\n mode: append\n"))
|
||||
policyOnly := Bytes("lower-policy", []byte("config:\n sequences:\n - destination: [items]\n key: id\n mode: append\n"))
|
||||
duplicate := func(name string) loadInput {
|
||||
return loadInput{source: Bytes(name, []byte("items: [{id: repeated}]\n"))}
|
||||
}
|
||||
@@ -380,7 +380,7 @@ func TestLayeredCollectionPolicyFlowsBetweenTiers(t *testing.T) {
|
||||
request = loadRequest[map[string]any]{
|
||||
main: loadInput{source: NoSource()},
|
||||
underlays: []loadGroup{
|
||||
{inputs: []loadInput{{source: Bytes("lower", []byte("configkit:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: repeated}]\n"))}}},
|
||||
{inputs: []loadInput{{source: Bytes("lower", []byte("config:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: repeated}]\n"))}}},
|
||||
{inputs: []loadInput{duplicate("higher")}},
|
||||
},
|
||||
}
|
||||
@@ -389,8 +389,8 @@ func TestLayeredCollectionPolicyFlowsBetweenTiers(t *testing.T) {
|
||||
}
|
||||
|
||||
request = loadRequest[map[string]any]{
|
||||
main: loadInput{source: Bytes("main", []byte("configkit:\n sequences:\n - destination: [items]\n key: name\n mode: replace\nitems: [{name: higher}]\n"))},
|
||||
underlays: []loadGroup{{inputs: []loadInput{{source: Bytes("lower", []byte("configkit:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: lower}]\n"))}}}},
|
||||
main: loadInput{source: Bytes("main", []byte("config:\n sequences:\n - destination: [items]\n key: name\n mode: replace\nitems: [{name: higher}]\n"))},
|
||||
underlays: []loadGroup{{inputs: []loadInput{{source: Bytes("lower", []byte("config:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: lower}]\n"))}}}},
|
||||
}
|
||||
result, err := testGroupedLoad(request)
|
||||
if err != nil || !reflect.DeepEqual(result.Config["items"], []any{map[string]any{"name": "higher"}}) {
|
||||
@@ -402,7 +402,7 @@ func TestLayeredCollectionPolicyFlowsBetweenTiers(t *testing.T) {
|
||||
}
|
||||
|
||||
filesystem := NewFilesystem("overlay", fstest.MapFS{
|
||||
"overlays/testing.yml": &fstest.MapFile{Data: []byte("configkit:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: overlay}]\n")},
|
||||
"overlays/testing.yml": &fstest.MapFile{Data: []byte("config:\n sequences:\n - destination: [items]\n key: id\n mode: append\nitems: [{id: overlay}]\n")},
|
||||
})
|
||||
definition := Definition[map[string]any]{sequenceIdentityRegistrations: []sequenceIdentityRegistration{{selector: sequenceIdentitySelector{literalSequenceSelector("items")}, identityFields: []string{"id"}}}}
|
||||
request = loadRequest[map[string]any]{
|
||||
@@ -433,7 +433,7 @@ func TestGroupedLoadStrictConflictsRepetitionAndBudgets(t *testing.T) {
|
||||
t.Fatalf("strict conflict code = %s", got)
|
||||
}
|
||||
conflicting := NewFilesystem("bundle", fstest.MapFS{
|
||||
"main.yml": &fstest.MapFile{Data: []byte("configkit: {imports: [{path: fragment.yml}]}\nport: 1\n")},
|
||||
"main.yml": &fstest.MapFile{Data: []byte("config: {imports: [{path: fragment.yml}]}\nport: 1\n")},
|
||||
"fragment.yml": &fstest.MapFile{Data: []byte("port: 2\n")},
|
||||
})
|
||||
request.main = loadInput{source: conflicting.File("main.yml"), imports: true}
|
||||
@@ -514,9 +514,9 @@ func groupedErrorCode(t *testing.T, err error) Code {
|
||||
|
||||
func TestGroupedAccountingChargesMixedOccurrencesOnce(t *testing.T) {
|
||||
const (
|
||||
one = "configkit: {imports: [{path: child-one.yml}]}\nleft: first\n"
|
||||
one = "config: {imports: [{path: child-one.yml}]}\nleft: first\n"
|
||||
child = "extra: imported\n"
|
||||
two = "configkit: {imports: [{path: child-two.yml}]}\nright: second\n"
|
||||
two = "config: {imports: [{path: child-two.yml}]}\nright: second\n"
|
||||
)
|
||||
filesystem := NewFilesystem("bundle", fstest.MapFS{
|
||||
"one.yml": &fstest.MapFile{Data: []byte(one)},
|
||||
@@ -551,7 +551,7 @@ func TestGroupedAccountingChargesMixedOccurrencesOnce(t *testing.T) {
|
||||
|
||||
func TestGroupedGlobEntryBudgetIsShared(t *testing.T) {
|
||||
filesystem := NewFilesystem("bundle", fstest.MapFS{
|
||||
"main.yml": &fstest.MapFile{Data: []byte("configkit: {imports: [{glob: 'parts/*.yml'}]}\n")},
|
||||
"main.yml": &fstest.MapFile{Data: []byte("config: {imports: [{glob: 'parts/*.yml'}]}\n")},
|
||||
"parts/a.yml": &fstest.MapFile{Data: []byte("left: one\n")},
|
||||
"parts/b.yml": &fstest.MapFile{Data: []byte("right: two\n")},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user