Skip to content

Commit 97b0be9

Browse files
[gateway] add tests for gateway chart (#251)
* add test with extended example values * increment version * assert full spec in basic test
1 parent cd0d4fd commit 97b0be9

File tree

4 files changed

+199
-3
lines changed

4 files changed

+199
-3
lines changed

charts/gateway/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ type: application
66
# This is the chart version. This version number should be incremented each time you make changes
77
# to the chart and its templates.
88
# Versions are expected to follow Semantic Versioning (https://semver.org/)
9-
version: 1.0.6
9+
version: 1.0.7
1010
annotations:
1111
artifacthub.io/changes: |
12-
- kind: fixed
13-
description: "chart formatting"
12+
- kind: added
13+
description: "unit tests for expected result"
1414
1515
sources:
1616
- https://github.com/subshell/helm-charts/tree/main/charts/gateway
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
suite: test gateway
3+
templates:
4+
- templates/gateway.yaml
5+
chart:
6+
version: 0.9.8
7+
tests:
8+
- it: should render with basic values
9+
release:
10+
name: basic-test-release
11+
values:
12+
- ./values/basic.yaml
13+
asserts:
14+
- containsDocument:
15+
kind: Gateway
16+
apiVersion: gateway.networking.k8s.io/v1beta1
17+
name: basic-test-release-gateway
18+
- equal:
19+
path: metadata.labels
20+
value:
21+
helm.sh/chart: gateway-0.9.8
22+
app.kubernetes.io/name: gateway
23+
app.kubernetes.io/instance: basic-test-release
24+
app.kubernetes.io/managed-by: Helm
25+
- lengthEqual:
26+
path: metadata.annotations
27+
count: 0
28+
- equal:
29+
path: spec
30+
value:
31+
gatewayClassName: "gke-l7-rilb"
32+
listeners:
33+
- name: "https-simple.example.com"
34+
hostname: "simple.example.com"
35+
port: 443
36+
protocol: HTTPS
37+
tls:
38+
mode: Terminate
39+
allowedRoutes:
40+
namespaces:
41+
from: All
42+
- notFailedTemplate: {}
43+
44+
- it: should use v1 api version if available
45+
release:
46+
name: basic-test-release
47+
values:
48+
- ./values/basic.yaml
49+
capabilities:
50+
apiVersions:
51+
- gateway.networking.k8s.io/v1
52+
asserts:
53+
- isAPIVersion:
54+
of: gateway.networking.k8s.io/v1
55+
56+
- it: should render with all values
57+
release:
58+
name: full-test-release
59+
values:
60+
- ./values/full.yaml
61+
asserts:
62+
- containsDocument:
63+
kind: Gateway
64+
apiVersion: gateway.networking.k8s.io/v1beta1
65+
name: full-test-release-testgateway
66+
- equal:
67+
path: metadata.labels
68+
value:
69+
helm.sh/chart: gateway-0.9.8
70+
app.kubernetes.io/name: testgateway
71+
app.kubernetes.io/instance: full-test-release
72+
app.kubernetes.io/managed-by: Helm
73+
- equal:
74+
path: metadata.annotations
75+
value:
76+
cert-manager.io/cluster-issuer: "acme-issuer"
77+
example.com/some.more: 1234
78+
example.com/template-value: This is a test
79+
- equal:
80+
path: spec
81+
value:
82+
gatewayClassName: "gke-l7-global-external-managed-mc"
83+
addresses:
84+
- type: NamedAddress
85+
value: chart-example-address
86+
- value: 1.2.3.4
87+
listeners:
88+
- hostname: other.example.com
89+
name: other-port
90+
port: 12345
91+
protocol: example.com/bar
92+
tls:
93+
certificateRefs:
94+
- group: foo.example.com
95+
kind: SpecialSecret
96+
name: other-certificate
97+
namspace: secret-ns
98+
mode: Terminate
99+
- name: http
100+
port: 80
101+
protocol: HTTP
102+
- name: "https-simple.example.com"
103+
hostname: "simple.example.com"
104+
port: 443
105+
protocol: HTTPS
106+
tls:
107+
mode: Terminate
108+
certificateRefs:
109+
- name: "gw-cert-simple.example.com"
110+
allowedRoutes:
111+
namespaces:
112+
from: All
113+
- name: "https-chart-example.local"
114+
hostname: "chart-example.local"
115+
port: 443
116+
protocol: HTTPS
117+
tls:
118+
mode: "Passthrough"
119+
certificateRefs:
120+
- name: "chart-example-tls"
121+
allowedRoutes:
122+
kinds:
123+
- group: gateway.example.com
124+
kind: ExampleRoute
125+
namespaces:
126+
from: Selector
127+
selector:
128+
matchLabels:
129+
example: use-gateway
130+
infrastructure:
131+
annotations:
132+
foo: bar
133+
labels:
134+
bar: foo
135+
parametersRef:
136+
group: settings.example.com
137+
kind: ExampleSettings
138+
name: example-settings
139+
- notFailedTemplate: {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gateway:
2+
https:
3+
- host: simple.example.com
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
nameOverride: testgateway
2+
fullnameOverride: ''
3+
4+
gateway:
5+
className: gke-l7-global-external-managed-mc
6+
annotations:
7+
example.com/template-value: This is a test
8+
example.com/some.more: 1234
9+
addresses:
10+
- type: NamedAddress
11+
value: chart-example-address
12+
- value: 1.2.3.4
13+
https:
14+
- host: simple.example.com
15+
- host: chart-example.local
16+
allowedRoutes:
17+
namespaces:
18+
from: Selector
19+
selector:
20+
matchLabels:
21+
example: use-gateway
22+
kinds:
23+
- group: gateway.example.com
24+
kind: ExampleRoute
25+
tls:
26+
mode: Passthrough
27+
certRef: chart-example-tls
28+
listeners:
29+
- name: other-port
30+
hostname: other.example.com
31+
port: 12345
32+
protocol: example.com/bar
33+
tls:
34+
mode: Terminate
35+
certificateRefs:
36+
- name: other-certificate
37+
namspace: secret-ns
38+
kind: SpecialSecret
39+
group: foo.example.com
40+
- name: http
41+
port: 80
42+
protocol: HTTP
43+
infrastructure:
44+
annotations:
45+
foo: bar
46+
labels:
47+
bar: foo
48+
parametersRef:
49+
group: settings.example.com
50+
kind: ExampleSettings
51+
name: example-settings
52+
53+
certManager:
54+
clusterIssuer: acme-issuer

0 commit comments

Comments
 (0)