helm-charts/charts/library/common-test/tests/ingress/service_reference_test.yaml
2024-03-08 08:51:40 +01:00

121 lines
3.3 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: ingress service reference
templates:
- common.yaml
values:
- ../_values/ingress_main_default_hosts.yaml
tests:
- it: default should pass
set:
service:
main:
controller: main
ports:
http:
port: &httpPort 8081
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend
value:
service:
name: RELEASE-NAME
port:
number: *httpPort
- it: custom service reference should pass
set:
ingress.main:
hosts:
- host: chart-test.local
paths:
- path: /
service:
name: pathService
port: 1234
asserts:
- documentIndex: &IngressDocument 1
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend
value:
service:
name: pathService
port:
number: 1234
- it: multiple hosts with port name references should pass
set:
service:
main:
controller: main
ports:
http:
port: &httpPort 8081
http2:
enabled: true
port: &http2Port 1880
ingress:
main:
className: "nginx"
hosts:
- host: http.chart-test.local
paths:
- path: /
pathType: Prefix
service:
name: main
port: http
- host: http2.chart-test.local
paths:
- path: /
pathType: Prefix
service:
name: main
port: http2
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
# First Ingress host
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].host
value: http.chart-test.local
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].path
value: "/"
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend.service.name
value: "RELEASE-NAME"
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend.service.port.number
value: *httpPort
# Second Ingress host
- documentIndex: *IngressDocument
equal:
path: spec.rules[1].host
value: http2.chart-test.local
- documentIndex: *IngressDocument
equal:
path: spec.rules[1].http.paths[0].path
value: "/"
- documentIndex: *IngressDocument
equal:
path: spec.rules[1].http.paths[0].backend.service.name
value: "RELEASE-NAME"
- documentIndex: *IngressDocument
equal:
path: spec.rules[1].http.paths[0].backend.service.port.number
value: *http2Port