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

92 lines
2.7 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: service metadata
templates:
- common.yaml
tests:
- it: default metadata should pass
values:
- ../_values/service_main_default.yaml
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
notExists:
path: metadata.annotations
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- it: custom metadata should pass
values:
- ../_values/service_main_default.yaml
set:
service:
main:
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
test_label: test
- it: custom metadata with global metadata should pass
values:
- ../_values/service_main_default.yaml
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
service:
main:
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME
global_label: test
helm.sh/chart: common-test-1.0.0
test_label: test