Files
kustomize/kyaml/yaml/merge2/list_test.go
Phillip Wittrock 5d1a0346b5 Use OpenAPI when merging (3way) resources
- When merging (3way) resources use the patch strategy from the openAPI if the definition exists for the field
- Allow disabling of guessing patch strategy merge keys when no definition exists
- Support defining strategy and key directly on configuration fields through line and header coments
- Support attaching schema to parent fields of lists, and propagating -- e.g. that a field is a PodTemplate
2020-03-02 20:56:53 -08:00

141 lines
1.4 KiB
Go

// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package merge2_test
var listTestCases = []testCase{
{description: `replace List -- different value in dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
dest: `
kind: Deployment
items:
- 0
- 1
`,
expected: `
kind: Deployment
items:
- 1
- 2
- 3
`,
},
{description: `replace List -- missing from dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
dest: `
kind: Deployment
`,
expected: `
kind: Deployment
items:
- 1
- 2
- 3
`,
},
//
// Test Case
//
{description: `keep List -- same value in src and dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
expected: `
kind: Deployment
items:
- 1
- 2
- 3
`,
},
//
// Test Case
//
{description: `keep List -- unspecified in src`,
source: `
kind: Deployment
`,
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
expected: `
kind: Deployment
items:
- 1
- 2
- 3
`,
},
//
// Test Case
//
{description: `remove List -- null in src`,
source: `
kind: Deployment
items: null
`,
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
expected: `
kind: Deployment
`,
},
//
// Test Case
//
{description: `remove list -- empty in src`,
source: `
kind: Deployment
items: {}
`,
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
expected: `
kind: Deployment
items: {}
`,
},
}