Skip to content

Commit

Permalink
Merge pull request #1467 from a7i/helm-unittest
Browse files Browse the repository at this point in the history
helm unit tests
  • Loading branch information
k8s-ci-robot authored Jul 16, 2024
2 parents c56a408 + 9b50263 commit a6e75fe
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ jobs:
with:
version: v3.7.0

- name: Install Helm Unit Test Plugin
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest
- name: Run Helm Unit Tests
run: |
helm unittest charts/descheduler --strict -d
- name: Run chart-testing (list-changed)
id: list-changed
run: |
Expand Down
1 change: 1 addition & 0 deletions charts/descheduler/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__snapshot__
17 changes: 17 additions & 0 deletions charts/descheduler/tests/cronjob_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
suite: Test Descheduler CronJob

templates:
- "*.yaml"

release:
name: descheduler

set:
kind: CronJob

tests:
- it: creates CronJob when kind is set
template: templates/cronjob.yaml
asserts:
- isKind:
of: CronJob
49 changes: 49 additions & 0 deletions charts/descheduler/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
suite: Test Descheduler Deployment

templates:
- "*.yaml"

release:
name: descheduler

set:
kind: Deployment

tests:
- it: creates Deployment when kind is set
template: templates/deployment.yaml
asserts:
- isKind:
of: Deployment

- it: enables leader-election
set:
leaderElection:
enabled: true
template: templates/deployment.yaml
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --leader-elect=true

- it: support leader-election resourceNamespace
set:
leaderElection:
enabled: true
resourceNamespace: test
template: templates/deployment.yaml
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --leader-elect-resource-namespace=test

- it: support legacy leader-election resourceNamescape
set:
leaderElection:
enabled: true
resourceNamescape: typo
template: templates/deployment.yaml
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --leader-elect-resource-namespace=typo

0 comments on commit a6e75fe

Please sign in to comment.