...
1
2
3
4 package krusty_test
5
6 import (
7 "testing"
8
9 kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
10 )
11
12 func TestNullValues1(t *testing.T) {
13 th := kusttest_test.MakeHarness(t)
14 th.WriteF("deployment.yaml", `
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18 labels:
19 app: example
20 name: example
21 spec:
22 selector:
23 matchLabels:
24 app: example
25 template:
26 metadata:
27 labels:
28 app: example
29 spec:
30 containers:
31 - args: null
32 image: image
33 name: example
34 `)
35 th.WriteF("kustomization.yaml", `
36 apiVersion: kustomize.config.k8s.io/v1beta1
37 kind: Kustomization
38 resources:
39 - deployment.yaml
40 `)
41 m := th.Run(".", th.MakeDefaultOptions())
42
43 th.AssertActualEqualsExpected(m, `
44 apiVersion: apps/v1
45 kind: Deployment
46 metadata:
47 labels:
48 app: example
49 name: example
50 spec:
51 selector:
52 matchLabels:
53 app: example
54 template:
55 metadata:
56 labels:
57 app: example
58 spec:
59 containers:
60 - args: null
61 image: image
62 name: example
63 `)
64 }
65
66 func TestNullValues2(t *testing.T) {
67 th := kusttest_test.MakeHarness(t)
68 th.WriteF("deploy.yaml", `
69 apiVersion: apps/v1
70 kind: Deployment
71 metadata:
72 name: test
73 spec:
74 template:
75 spec:
76 containers:
77 - name: test
78 volumes: null
79 `)
80 th.WriteK(".", `
81 resources:
82 - deploy.yaml
83 `)
84 m := th.Run(".", th.MakeDefaultOptions())
85 th.AssertActualEqualsExpected(m, `
86 apiVersion: apps/v1
87 kind: Deployment
88 metadata:
89 name: test
90 spec:
91 template:
92 spec:
93 containers:
94 - name: test
95 volumes: null
96 `)
97 }
98
View as plain text