helm-charts/charts/library/common-test/tests/controller/cronjob_test.yaml
2023-09-14 15:40:49 +02:00

80 lines
2.5 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: cronjob configuration
templates:
- common.yaml
tests:
- it: default cronjob configuration should pass
set:
controllers:
main:
type: cronjob
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: CronJob
- documentIndex: *ControllerDoc
equal:
path: spec.schedule
value: "*/20 * * * *"
- documentIndex: *ControllerDoc
equal:
path: spec.concurrencyPolicy
value: Forbid
- documentIndex: *ControllerDoc
equal:
path: spec.successfulJobsHistoryLimit
value: 1
- documentIndex: *ControllerDoc
equal:
path: spec.failedJobsHistoryLimit
value: 1
- documentIndex: *ControllerDoc
notExists:
path: spec.jobTemplate.spec.ttlSecondsAfterFinished
- documentIndex: *ControllerDoc
equal:
path: spec.jobTemplate.spec.template.spec.restartPolicy
value: Never
- it: custom cronjob configuration should pass
set:
controllers:
main:
type: cronjob
pod:
restartPolicy: OnFailure
cronjob:
schedule: &CronJobSchedule "0 3 * * *"
concurrencyPolicy: &CronJobConcurrencyPolicy "Test"
failedJobsHistory: &CronJobFailedJobsHistory 2
successfulJobsHistory: &CronJobSuccessfulJobsHistory 3
ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: CronJob
- documentIndex: *ControllerDoc
equal:
path: spec.schedule
value: *CronJobSchedule
- documentIndex: *ControllerDoc
equal:
path: spec.concurrencyPolicy
value: *CronJobConcurrencyPolicy
- documentIndex: *ControllerDoc
equal:
path: spec.successfulJobsHistoryLimit
value: *CronJobSuccessfulJobsHistory
- documentIndex: *ControllerDoc
equal:
path: spec.failedJobsHistoryLimit
value: *CronJobFailedJobsHistory
- documentIndex: *ControllerDoc
equal:
path: spec.jobTemplate.spec.ttlSecondsAfterFinished
value: *ttlSecondsAfterFinished
- documentIndex: *ControllerDoc
equal:
path: spec.jobTemplate.spec.template.spec.restartPolicy
value: OnFailure