mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 09:02:53 +00:00
add testting for patch transformers
This commit is contained in:
@@ -250,7 +250,7 @@ spec:
|
||||
`)
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerWithInline(t *testing.T) {
|
||||
func TestPatchJson6902TransformerWithInlineJSON(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
@@ -290,3 +290,47 @@ spec:
|
||||
dnsPolicy: ClusterFirst
|
||||
`)
|
||||
}
|
||||
|
||||
func TestPatchJson6902TransformerWithInlineYAML(t *testing.T) {
|
||||
tc := plugins_test.NewEnvForTest(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildGoPlugin(
|
||||
"builtin", "", "PatchJson6902Transformer")
|
||||
|
||||
th := kusttest_test.NewKustTestPluginHarness(t, "/app")
|
||||
|
||||
rm := th.LoadAndRunTransformer(`
|
||||
apiVersion: builtin
|
||||
kind: PatchJson6902Transformer
|
||||
metadata:
|
||||
name: notImportantHere
|
||||
target:
|
||||
group: apps
|
||||
version: v1
|
||||
kind: Deployment
|
||||
name: myDeploy
|
||||
jsonOp: |-
|
||||
- op: add
|
||||
path: /spec/template/spec/dnsPolicy
|
||||
value: ClusterFirst
|
||||
`, target)
|
||||
|
||||
th.AssertActualEqualsExpected(rm, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: myDeploy
|
||||
spec:
|
||||
replica: 2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
old-label: old-value
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
dnsPolicy: ClusterFirst
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user