helm-charts/charts/library/common-test/tests/container/volumemounts_test.yaml
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 66389dec8b
feat(common): Release 2.0.1 (#193)
2023-10-03 09:24:41 +02:00

275 lines
7.5 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container volumeMounts
templates:
- common.yaml
tests:
- it: no persistence should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
notExists:
path: spec.template.spec.containers[0].volumeMounts
- it: default should pass
set:
persistence:
config:
enabled: true
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
- it: advanced mount config should pass
set:
controllers:
main:
containers:
second-container:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 30
persistence:
data:
type: configMap
name: myConfigMap
globalMounts:
- path: /globalTest
advancedMounts:
main:
main:
- path: /data/config.yaml
readOnly: false
subPath: config.yaml
second-container:
- path: /appdata/config
readOnly: true
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: data
mountPath: /globalTest
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[1]
value:
name: data
mountPath: /data/config.yaml
subPath: config.yaml
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[0]
value:
name: data
mountPath: /globalTest
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[1]
value:
name: data
mountPath: /appdata/config
readOnly: true
- it: emptyDir should pass
set:
persistence:
cache:
type: emptyDir
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: cache
mountPath: /cache
- it: custom mountPath should pass
set:
persistence:
config:
enabled: true
accessMode: ReadWriteMany
size: 1G
globalMounts:
- path: /custom
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /custom
- it: mount with subPath should pass
set:
persistence:
config:
enabled: true
existingClaim: myClaim
globalMounts:
- path: /config
subPath: "mySubPath"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
subPath: mySubPath
- it: hostPath with custom mountPath should pass
set:
persistence:
config:
enabled: true
type: hostPath
hostPath: /tmp
globalMounts:
- path: /data
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /data
- it: hostPath mount with subPath should pass
set:
persistence:
config:
enabled: true
type: hostPath
hostPath: /dev
globalMounts:
- subPath: mySubPath
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /dev
subPath: mySubPath
- it: volumeClaimTemplates with default mounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: storage
mountPath: /storage
- it: volumeClaimTemplates with globalMounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
globalMounts:
- path: /tmp/storage
- path: /tmp/secondMountPoint
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: storage
mountPath: /tmp/storage
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[1]
value:
name: storage
mountPath: /tmp/secondMountPoint
- it: volumeClaimTemplates with advancedMounts should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
advancedMounts:
second-container:
- path: /tmp/storage
- path: /tmp/secondMountPoint
containers:
second-container:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 30
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
notExists:
path: spec.template.spec.containers[0].volumeMounts
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[0]
value:
name: storage
mountPath: /tmp/storage
- documentIndex: *StatefulSetDoc
equal:
path: spec.template.spec.containers[1].volumeMounts[1]
value:
name: storage
mountPath: /tmp/secondMountPoint