helm-charts/charts/library/common-test/tests/pvc/datasource_test.yaml
2024-03-07 18:53:41 +00:00

111 lines
3.2 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pvc datasource
templates:
- common.yaml
set:
persistence.config:
accessMode: ReadWriteOnce
size: 1Gi
tests:
- it: default should pass
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: with dataSource should pass
set:
persistence.config:
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSource
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: templated dataSource name should pass
set:
persistence.config:
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSource
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: RELEASE-NAME-config
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: with dataSourceRef should pass
set:
persistence.config:
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSourceRef
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource
- it: templated dataSourceRef name should pass
set:
persistence.config:
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSourceRef
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: RELEASE-NAME-config
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource