2025-05-23 07:43:19 +03:00

142 lines
3.2 KiB
YAML

# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test extraManifests
templates:
- extra-objects.yaml
tests:
- it: should handle empty manifests gracefully
set:
extraManifests: []
asserts:
- hasDocuments:
count: 0
- it: should process a single string manifest
set:
extraManifests:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
asserts:
- isKind:
of: ConfigMap
- equal:
path: metadata.name
value: test-cm
- it: should process string manifest with tpl values
set:
name: myapp
extraManifests:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.name }}-cm
asserts:
- equal:
path: metadata.name
value: myapp-cm
- it: should process string manifest with tpl function
set:
name: MyApp
extraManifests:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ lower .Values.name }}-cm
asserts:
- equal:
path: metadata.name
value: myapp-cm
- it: should process a single map manifest
set:
extraManifests:
- apiVersion: v1
kind: Secret
metadata:
name: test-secret
asserts:
- equal:
path: kind
value: Secret
- equal:
path: metadata.name
value: test-secret
- it: should process map manifest with tpl values
set:
env: prod
extraManifests:
- apiVersion: v1
kind: ConfigMap
metadata:
name: config-{{ .Values.env }}
asserts:
- equal:
path: metadata.name
value: config-prod
- it: should process multiple slice-based manifests with tpl
set:
version: v1
extraManifests:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-{{ .Values.version }}
- apiVersion: v1
kind: Secret
metadata:
name: secret-{{ .Values.version }}
asserts:
- hasDocuments:
count: 2
- equal:
path: metadata.name
value: cm-v1
documentSelector:
path: kind
value: ConfigMap
- equal:
path: metadata.name
value: secret-v1
documentSelector:
path: kind
value: Secret
- it: should handle multiple map-based manifests with tpl
set:
app: myapp
extraManifests:
cm1:
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Values.app }}-cm1"
secret1:
apiVersion: v1
kind: Secret
metadata:
name: "{{ .Values.app }}-secret1"
asserts:
- hasDocuments:
count: 2
- equal:
path: metadata.name
value: myapp-cm1
documentSelector:
path: kind
value: ConfigMap
- equal:
path: metadata.name
value: myapp-secret1
documentSelector:
path: kind
value: Secret