Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
awakair committed Oct 29, 2024
1 parent d526cd1 commit 137d5ba
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
66 changes: 66 additions & 0 deletions api/filters/patchstrategicmerge/patchstrategicmerge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,8 @@ spec:
containers:
- name: foo1
- name: foo2
- name: duplicate
image: duplicate:1.1.0
- name: foo3
`,
patch: yaml.MustParse(`
Expand All @@ -952,6 +954,8 @@ spec:
spec:
containers:
- name: foo0
- name: duplicate
image: duplicate:2.1.0
`),
expected: `
apiVersion: apps/v1
Expand All @@ -964,6 +968,8 @@ spec:
containers:
- name: foo1
- name: foo2
- name: duplicate
image: duplicate:2.1.0
- name: foo3
- name: foo0
`,
Expand Down Expand Up @@ -1047,6 +1053,66 @@ spec:
image: test
- name: test2
image: test2
`,
},
"merge to empty list": {
input: `
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
`,
patch: yaml.MustParse(`
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
spec:
template:
spec:
containers:
- name: foo0
`),
expected: `
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
spec:
template:
spec:
containers:
- name: foo0
`,
},
"merge with empty list": {
input: `
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
spec:
template:
spec:
containers:
- name: foo0
`,
patch: yaml.MustParse(`
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
`),
expected: `
apiVersion: apps/v1
metadata:
name: myDeploy
kind: Deployment
spec:
template:
spec:
containers:
- name: foo0
`,
},
}
Expand Down
68 changes: 68 additions & 0 deletions api/krusty/baseandoverlaymedium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ spec:
value: bar
ports:
- containerPort: 80
- name: tg-bot
image: python
env:
- name: first
value: first
- name: second
value: second
- name: web-server
image: alpine
`)
}

Expand Down Expand Up @@ -94,6 +103,15 @@ spec:
name: nginx
ports:
- containerPort: 80
- env:
- name: first
value: first
- name: second
value: second
image: python
name: tg-bot
- image: alpine
name: web-server
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -176,6 +194,17 @@ spec:
configMapKeyRef:
name: app-env
key: somekey
- name: tg-bot
env:
- name: third
value: third
- name: first
value: fourth
- name: web-server
image: alpine
env:
- name: foo
value: bar
- name: busybox
image: busybox
envFrom:
Expand Down Expand Up @@ -237,6 +266,20 @@ spec:
name: nginx
ports:
- containerPort: 80
- env:
- name: third
value: third
- name: first
value: fourth
- name: second
value: second
image: python
name: tg-bot
- env:
- name: foo
value: bar
image: alpine
name: web-server
- envFrom:
- configMapRef:
name: someConfigMap
Expand Down Expand Up @@ -370,6 +413,17 @@ spec:
configMapKeyRef:
name: app-env
key: somekey
- name: tg-bot
env:
- name: third
value: third
- name: first
value: fourth
- name: web-server
image: alpine
env:
- name: foo
value: bar
- name: busybox
image: busybox
envFrom:
Expand Down Expand Up @@ -433,6 +487,20 @@ spec:
name: nginx
ports:
- containerPort: 80
- env:
- name: first
value: fourth
- name: second
value: second
- name: third
value: third
image: python
name: tg-bot
- env:
- name: foo
value: bar
image: alpine
name: web-server
- envFrom:
- configMapRef:
name: someConfigMap
Expand Down

0 comments on commit 137d5ba

Please sign in to comment.