Skip to content

Instantly share code, notes, and snippets.

@TheRealNoob
Created March 18, 2025 10:05
Show Gist options
  • Save TheRealNoob/ca7dee0e862a4e5526a115d54e863ec9 to your computer and use it in GitHub Desktop.
Save TheRealNoob/ca7dee0e862a4e5526a115d54e863ec9 to your computer and use it in GitHub Desktop.
suite: Test passthrough helm chart
templates:
- templates/manifests.yaml
tests:
- it: should handle empty manifests gracefully
set:
manifests: []
asserts:
- hasDocuments:
count: 0
- it: should process a single string manifest
set:
manifests:
- |
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
manifests:
- |
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
manifests:
- |
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:
manifests:
- 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
manifests:
- 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
manifests:
- |
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
manifests:
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment