Skip to content

Commit 93dc58e

Browse files
committed
Convert snapshot test to assertions
1 parent 14ad656 commit 93dc58e

File tree

2 files changed

+119
-64
lines changed

2 files changed

+119
-64
lines changed

charts/hdx-oss-v2/tests/__snapshot__/ingress_test.yaml.snap

Lines changed: 0 additions & 60 deletions
This file was deleted.

charts/hdx-oss-v2/tests/ingress_test.yaml

Lines changed: 119 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,63 @@ tests:
9999
asserts:
100100
- hasDocuments:
101101
count: 2
102-
- matchSnapshot: {}
103-
documentSelector:
102+
# Test the main app ingress (document 0)
103+
- isKind:
104+
of: Ingress
105+
documentIndex: 0
106+
- equal:
107+
path: metadata.name
108+
value: RELEASE-NAME-hdx-oss-v2-app-ingress
109+
documentIndex: 0
110+
- equal:
111+
path: spec.rules[0].host
112+
value: hyperdx.example.com
113+
documentIndex: 0
114+
# Test the additional otel-collector ingress (document 1)
115+
- isKind:
116+
of: Ingress
117+
documentIndex: 1
118+
- equal:
104119
path: metadata.name
105120
value: RELEASE-NAME-hdx-oss-v2-otel-collector
121+
documentIndex: 1
122+
- equal:
123+
path: metadata.annotations.testProperty
124+
value: "true"
125+
documentIndex: 1
126+
- equal:
127+
path: metadata.annotations.another
128+
value: "yes"
129+
documentIndex: 1
130+
- equal:
131+
path: spec.ingressClassName
132+
value: nginx
133+
documentIndex: 1
134+
- equal:
135+
path: spec.rules[0].host
136+
value: collector.example.com
137+
documentIndex: 1
138+
- equal:
139+
path: spec.rules[0].http.paths[0].path
140+
value: /
141+
documentIndex: 1
142+
- equal:
143+
path: spec.rules[0].http.paths[0].pathType
144+
value: Prefix
145+
documentIndex: 1
146+
- equal:
147+
path: spec.rules[0].http.paths[0].backend.service.port.number
148+
value: 4318
149+
documentIndex: 1
150+
# Validate version-agnostic labels exist
151+
- matchRegex:
152+
path: metadata.labels["helm.sh/chart"]
153+
pattern: ^hdx-oss-v2-\d+\.\d+\.\d+$
154+
documentIndex: 1
155+
- matchRegex:
156+
path: metadata.labels["app.kubernetes.io/version"]
157+
pattern: ^\d+\.\d+\.\d+$
158+
documentIndex: 1
106159

107160
- it: should render additional ingress templates with TLS enabled
108161
set:
@@ -131,10 +184,72 @@ tests:
131184
asserts:
132185
- hasDocuments:
133186
count: 2
134-
- matchSnapshot: {}
135-
documentSelector:
187+
# Test the main app ingress (document 0)
188+
- isKind:
189+
of: Ingress
190+
documentIndex: 0
191+
- equal:
192+
path: metadata.name
193+
value: RELEASE-NAME-hdx-oss-v2-app-ingress
194+
documentIndex: 0
195+
- equal:
196+
path: spec.rules[0].host
197+
value: hyperdx.example.com
198+
documentIndex: 0
199+
# Test the additional otel-collector ingress (document 1)
200+
- isKind:
201+
of: Ingress
202+
documentIndex: 1
203+
- equal:
136204
path: metadata.name
137205
value: RELEASE-NAME-hdx-oss-v2-otel-collector
206+
documentIndex: 1
207+
- equal:
208+
path: metadata.annotations.testProperty
209+
value: "true"
210+
documentIndex: 1
211+
- equal:
212+
path: metadata.annotations.another
213+
value: "yes"
214+
documentIndex: 1
215+
- equal:
216+
path: spec.ingressClassName
217+
value: nginx
218+
documentIndex: 1
219+
- equal:
220+
path: spec.rules[0].host
221+
value: collector.example.com
222+
documentIndex: 1
223+
- equal:
224+
path: spec.rules[0].http.paths[0].path
225+
value: /
226+
documentIndex: 1
227+
- equal:
228+
path: spec.rules[0].http.paths[0].pathType
229+
value: Prefix
230+
documentIndex: 1
231+
- equal:
232+
path: spec.rules[0].http.paths[0].backend.service.port.number
233+
value: 4318
234+
documentIndex: 1
235+
# Test TLS configuration
236+
- equal:
237+
path: spec.tls[0].secretName
238+
value: otel-collector-tls
239+
documentIndex: 1
240+
- contains:
241+
path: spec.tls[0].hosts
242+
content: collector.example.com
243+
documentIndex: 1
244+
# Validate version-agnostic labels exist
245+
- matchRegex:
246+
path: metadata.labels["helm.sh/chart"]
247+
pattern: ^hdx-oss-v2-\d+\.\d+\.\d+$
248+
documentIndex: 1
249+
- matchRegex:
250+
path: metadata.labels["app.kubernetes.io/version"]
251+
pattern: ^\d+\.\d+\.\d+$
252+
documentIndex: 1
138253

139254
- it: should fail when annotations of the additional ingresses is not a map of strings
140255
set:

0 commit comments

Comments
 (0)