mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
convert tests to exercise openapi and inference
This commit is contained in:
@@ -6,21 +6,33 @@ package merge2_test
|
|||||||
var elementTestCases = []testCase{
|
var elementTestCases = []testCase{
|
||||||
{description: `merge Element -- keep field in dest`,
|
{description: `merge Element -- keep field in dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
@@ -29,21 +41,33 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add field to dest`,
|
{description: `merge Element -- add field to dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
@@ -52,19 +76,31 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add list, empty in dest`,
|
{description: `merge Element -- add list, empty in dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: []
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: []
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
@@ -73,18 +109,27 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add list, missing from dest`,
|
{description: `merge Element -- add list, missing from dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
@@ -93,8 +138,12 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add Element first`,
|
{description: `merge Element -- add Element first`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
@@ -102,14 +151,22 @@ items:
|
|||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -120,8 +177,12 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add Element second`,
|
{description: `merge Element -- add Element second`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -129,14 +190,22 @@ items:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -150,11 +219,16 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep list -- list missing from src`,
|
{description: `keep list -- list missing from src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -162,8 +236,12 @@ items:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -177,14 +255,22 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep Element -- element missing in src`,
|
{description: `keep Element -- element missing in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -192,8 +278,12 @@ items:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -207,12 +297,20 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep element -- empty list in src`,
|
{description: `keep element -- empty list in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: {}
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: {}
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -220,8 +318,12 @@ items:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -235,12 +337,20 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `remove Element -- null in src`,
|
{description: `remove Element -- null in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: null
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: null
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
@@ -248,33 +358,41 @@ items:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `no infer merge keys no merge'`,
|
{description: `infer merge keys merge'`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -282,8 +400,8 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using schema`,
|
{description: `no infer merge keys merge using schema`,
|
||||||
source: `
|
source: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -292,8 +410,8 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -302,8 +420,8 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -312,7 +430,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -320,24 +438,27 @@ spec:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func TestMerge(t *testing.T) {
|
|||||||
for j := range testCases[i] {
|
for j := range testCases[i] {
|
||||||
tc := testCases[i][j]
|
tc := testCases[i][j]
|
||||||
t.Run(tc.description, func(t *testing.T) {
|
t.Run(tc.description, func(t *testing.T) {
|
||||||
actual, err := MergeStrings(tc.source, tc.dest, !tc.noInfer)
|
actual, err := MergeStrings(tc.source, tc.dest, tc.infer)
|
||||||
if !assert.NoError(t, err, tc.description) {
|
if !assert.NoError(t, err, tc.description) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
@@ -47,5 +47,5 @@ type testCase struct {
|
|||||||
source string
|
source string
|
||||||
dest string
|
dest string
|
||||||
expected string
|
expected string
|
||||||
noInfer bool
|
infer bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,28 @@
|
|||||||
|
|
||||||
package merge3_test
|
package merge3_test
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
var elementTestCases = []testCase{
|
var elementTestCases = []testCase{
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `Add an element to an existing list`,
|
{description: `Add an element to an existing list`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
@@ -23,19 +32,26 @@ containers:
|
|||||||
image: baz:2
|
image: baz:2
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
- image: baz:2
|
- image: baz:2
|
||||||
name: baz
|
name: baz
|
||||||
|
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -43,18 +59,28 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add an element to a non-existing list`,
|
{description: `Add an element to a non-existing list`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment`,
|
kind: Deployment`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- image: foo:bar
|
- image: foo:bar
|
||||||
name: foo
|
name: foo
|
||||||
@@ -62,21 +88,34 @@ containers:
|
|||||||
|
|
||||||
{description: `Add an element to a non-existing list, existing in dest`,
|
{description: `Add an element to a non-existing list, existing in dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment`,
|
kind: Deployment`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: baz
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: baz
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
@@ -90,12 +129,20 @@ containers:
|
|||||||
// This element is missing from the destination -- only the new fields are added
|
// This element is missing from the destination -- only the new fields are added
|
||||||
{description: `Add a field to the element, element missing from dest`,
|
{description: `Add a field to the element, element missing from dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar`,
|
image: foo:bar`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -103,10 +150,15 @@ containers:
|
|||||||
- run.sh
|
- run.sh
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- command:
|
- command:
|
||||||
- run.sh
|
- run.sh
|
||||||
@@ -118,7 +170,11 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Update a field on the elem, element missing from the dest`,
|
{description: `Update a field on the elem, element missing from the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -126,7 +182,11 @@ containers:
|
|||||||
- run.sh
|
- run.sh
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -134,10 +194,15 @@ containers:
|
|||||||
- run2.sh
|
- run2.sh
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- command:
|
- command:
|
||||||
- run2.sh
|
- run2.sh
|
||||||
@@ -149,28 +214,44 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Update a field on the elem, element present in the dest`,
|
{description: `Update a field on the elem, element present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -182,26 +263,42 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add a field on the elem, element present in the dest`,
|
{description: `Add a field on the elem, element present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -213,27 +310,43 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add a field on the elem, element and field present in the dest`,
|
{description: `Add a field on the elem, element and field present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -245,21 +358,37 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Ignore an element`,
|
{description: `Ignore an element`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers: {}
|
containers: {}
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers: {}
|
containers: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -270,18 +399,25 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Leave deleted`,
|
{description: `Leave deleted`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`},
|
`},
|
||||||
|
|
||||||
@@ -290,22 +426,38 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- matching`,
|
{description: `Remove an element -- matching`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -313,23 +465,39 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- field missing from update`,
|
{description: `Remove an element -- field missing from update`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -337,7 +505,11 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- element missing`,
|
{description: `Remove an element -- element missing`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -345,13 +517,21 @@ containers:
|
|||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -360,7 +540,11 @@ containers:
|
|||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
@@ -372,24 +556,40 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- empty containers`,
|
{description: `Remove an element -- empty containers`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers: {}
|
containers: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -397,53 +597,82 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- missing list field`,
|
{description: `Remove an element -- missing list field`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `no infer merge keys no merge'`,
|
{description: `infer merge keys merge'`,
|
||||||
origin: `
|
origin: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -451,8 +680,8 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using schema`,
|
{description: `no infer merge keys merge using schema`,
|
||||||
origin: `
|
origin: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -460,8 +689,8 @@ spec:
|
|||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -470,8 +699,8 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -480,8 +709,8 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -490,7 +719,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -498,30 +727,46 @@ spec:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -529,32 +774,48 @@ containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"t
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as head comment'`,
|
{description: `no infer merge keys merge using explicit schema as head comment'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
containers:
|
containers:
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
containers:
|
containers:
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -562,12 +823,14 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema to parent field'`,
|
{description: `no infer merge keys merge using explicit schema to parent field'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
@@ -575,6 +838,7 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
containers:
|
containers:
|
||||||
@@ -582,6 +846,7 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
containers:
|
containers:
|
||||||
@@ -589,7 +854,7 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -597,12 +862,14 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema to parent field header'`,
|
{description: `no infer merge keys merge using explicit schema to parent field header'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
@@ -610,6 +877,7 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
spec:
|
spec:
|
||||||
@@ -618,6 +886,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
spec:
|
spec:
|
||||||
@@ -626,6 +895,6 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestMerge(t *testing.T) {
|
|||||||
for j := range testCases[i] {
|
for j := range testCases[i] {
|
||||||
tc := testCases[i][j]
|
tc := testCases[i][j]
|
||||||
t.Run(tc.description, func(t *testing.T) {
|
t.Run(tc.description, func(t *testing.T) {
|
||||||
actual, err := MergeStrings(tc.local, tc.origin, tc.update, !tc.noInfer)
|
actual, err := MergeStrings(tc.local, tc.origin, tc.update, tc.infer)
|
||||||
if tc.err == nil {
|
if tc.err == nil {
|
||||||
if !assert.NoError(t, err, tc.description) {
|
if !assert.NoError(t, err, tc.description) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
@@ -47,5 +47,5 @@ type testCase struct {
|
|||||||
local string
|
local string
|
||||||
expected string
|
expected string
|
||||||
err error
|
err error
|
||||||
noInfer bool
|
infer bool
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user