Skip to content

Commit 48b4976

Browse files
committed
test: add tests
1 parent 8140b0e commit 48b4976

5 files changed

Lines changed: 206 additions & 0 deletions

tests/deployment_default_test.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
suite: test default deployment
2+
chart:
3+
version: 9.9.9+test
4+
appVersion: 9.9.9
5+
tests:
6+
- it: should have correct metadata
7+
template: templates/deployment.yaml
8+
asserts:
9+
- hasDocuments:
10+
count: 1
11+
- isAPIVersion:
12+
of: apps/v1
13+
- isKind:
14+
of: Deployment
15+
- equal:
16+
path: metadata.labels["app.kubernetes.io/version"]
17+
value: 9.9.9
18+
- equal:
19+
path: spec.template.spec.serviceAccountName
20+
value: RELEASE-NAME-emby
21+
- equal:
22+
path: metadata.labels["helm.sh/chart"]
23+
value: emby-9.9.9_test
24+
25+
- it: should render volumes and volumeMounts correctly
26+
template: templates/deployment.yaml
27+
asserts:
28+
- lengthEqual:
29+
path: spec.template.spec.volumes
30+
count: 1
31+
- exists:
32+
path: spec.template.spec.volumes[0].emptyDir
33+
- lengthEqual:
34+
path: spec.template.spec.containers[0].volumeMounts
35+
count: 1
36+
37+
- it: should render correct container content
38+
template: templates/deployment.yaml
39+
asserts:
40+
- exists:
41+
path: spec.template.spec.containers
42+
- exists:
43+
path: spec.template.spec.containers[0].readinessProbe
44+
- exists:
45+
path: spec.template.spec.containers[0].livenessProbe
46+
- contains:
47+
path: spec.template.spec.containers[0].ports
48+
content:
49+
name: http
50+
containerPort: 8096
51+
protocol: TCP
52+
- matchRegex:
53+
path: spec.template.spec.containers[0].image
54+
pattern: emby/embyserver:.*
55+
- isNotNullOrEmpty:
56+
path: spec.template.spec.containers[0]
57+
- lengthEqual:
58+
path: spec.template.spec.containers[0].ports
59+
count: 1
60+
- isNullOrEmpty:
61+
path: spec.template.spec.containers[0].resources
62+
- exists:
63+
path: spec.template.spec.containers[0].env
64+
- lengthEqual:
65+
path: spec.template.spec.containers[0].env
66+
count: 3
67+
- notExists:
68+
path: spec.template.spec.containers[1]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
suite: test deployment with persistence enabled
2+
chart:
3+
version: 9.9.9+test
4+
appVersion: 9.9.9
5+
tests:
6+
- it: should render correct content when using not existing PVC
7+
template: templates/deployment.yaml
8+
set:
9+
persistence.enabled: true
10+
documentIndex: 0
11+
asserts:
12+
- hasDocuments:
13+
count: 1
14+
- exists:
15+
path: spec.template.spec.volumes[0].persistentVolumeClaim
16+
- equal:
17+
path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName
18+
value: RELEASE-NAME-emby-config
19+
- lengthEqual:
20+
path: spec.template.spec.containers[0].volumeMounts
21+
count: 1
22+
23+
- it: should render correct content when using existing PVC
24+
template: templates/deployment.yaml
25+
set:
26+
persistence.enabled: true
27+
persistence.existingClaim: "test"
28+
asserts:
29+
- hasDocuments:
30+
count: 1
31+
- exists:
32+
path: spec.template.spec.volumes[0].persistentVolumeClaim
33+
- equal:
34+
path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName
35+
value: test
36+
- lengthEqual:
37+
path: spec.template.spec.containers[0].volumeMounts
38+
count: 1
39+
40+
- it: should render correct content when using additional volumes and volumeMounts
41+
template: templates/deployment.yaml
42+
set:
43+
persistence.enabled: true
44+
additionalVolumes:
45+
- name: test
46+
nfs:
47+
path: /nfs-path
48+
server: my-nfs-server
49+
- name: cfmp
50+
configMap:
51+
name: test-map
52+
items:
53+
- key: config.yaml
54+
path: /config
55+
additionalVolumeMounts:
56+
- name: test
57+
mountPath: /mnt
58+
subPath: data
59+
- name: cfmp
60+
mountPath: /server.yaml
61+
subPath: server
62+
documentIndex: 0
63+
asserts:
64+
- hasDocuments:
65+
count: 1
66+
- lengthEqual:
67+
path: spec.template.spec.volumes
68+
count: 3
69+
- lengthEqual:
70+
path: spec.template.spec.containers[0].volumeMounts
71+
count: 3
72+
- equal:
73+
path: spec.template.spec.volumes[1].name
74+
value: test
75+
- equal:
76+
path: spec.template.spec.volumes[2].name
77+
value: cfmp
78+
- equal:
79+
path: spec.template.spec.containers[0].volumeMounts[1].name
80+
value: test
81+
- equal:
82+
path: spec.template.spec.containers[0].volumeMounts[2].name
83+
value: cfmp

tests/ingress_default_test.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
suite: test default ingress
2+
chart:
3+
version: 9.9.9+test
4+
appVersion: 9.9.9
5+
tests:
6+
- it: shouldn't render
7+
template: templates/ingress.yaml
8+
asserts:
9+
- hasDocuments:
10+
count: 0

tests/ingress_enabled_test.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
suite: test ingress when enabled
2+
chart:
3+
version: 9.9.9+test
4+
appVersion: 9.9.9
5+
tests:
6+
- it: should have correct metadata
7+
template: templates/ingress.yaml
8+
set:
9+
ingress.enabled: true
10+
asserts:
11+
- hasDocuments:
12+
count: 1
13+
- isAPIVersion:
14+
of: networking.k8s.io/v1
15+
- isKind:
16+
of: Ingress
17+
- equal:
18+
path: metadata.name
19+
value: RELEASE-NAME-emby

tests/service_default_test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
suite: test default service
2+
chart:
3+
version: 9.9.9+test
4+
appVersion: 9.9.9
5+
tests:
6+
- it: should render default service
7+
template: templates/service.yaml
8+
asserts:
9+
- hasDocuments:
10+
count: 1
11+
- isAPIVersion:
12+
of: v1
13+
- isKind:
14+
of: Service
15+
- equal:
16+
path: metadata.name
17+
value: RELEASE-NAME-emby
18+
- equal:
19+
path: spec.type
20+
value: ClusterIP
21+
22+
- it: should not render LB service
23+
template: templates/service-LB.yaml
24+
asserts:
25+
- hasDocuments:
26+
count: 0

0 commit comments

Comments
 (0)