helm-charts/charts/library/common-test/tests/networkpolicy/metadata_test.yaml
2024-03-15 08:33:07 +00:00

94 lines
2.6 KiB
YAML

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