Skip to content

Commit 17ef7c2

Browse files
committed
simplify helm-unittest usage
1 parent a4b841e commit 17ef7c2

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
- name: Run helm-unittest
4343
# by default looks for tests/*_test.yaml
4444
run: |
45-
helm unittest --color --helm3 -f tests/unit/*_test.yaml .
45+
helm unittest --color --helm3 .

tests/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# `stackstorm-ha` Helm chart Tests
22

3-
This directory contains Helm chart integration and unit tests (under `tests/integration/` and `tests/unit/` respectively).
3+
This directory contains Helm chart integration (under `tests/integration/`) and unit tests (`tests/unit-*_test.yaml`).
44

55
## Unit tests
66

7-
Unit tests (under `tests/unit/`) use [`helm-unittest`](https://github.com/quintush/helm-unittest).
7+
Unit tests (`tests/unit-*_test.yaml`) use [`helm-unittest`](https://github.com/quintush/helm-unittest).
88
`helm-unittest` uses a yaml-based test file to ensure that the templates generate expected features.
99
For example, they can ensure that custom annotations are applied consistently to all of the deployments.
1010
Unit tests do not require a running kubernetes cluster.
@@ -17,11 +17,16 @@ helm dependency update
1717

1818
To run the tests manually from the chart's root dir:
1919
```
20-
helm unittest --helm3 tests/unit/*_test.yaml .
20+
helm unittest --helm3 .
2121
```
2222

2323
Note that `helm-unittest` still defaults to helm 2, so you must pass `--helm3` or `-3` for short.
24-
You must also tell it where the unit tests are with `-f` because we keep unit tests in the `tests/unit` directory.
24+
`helm-unittest` does not have a configuraiton file which makes using non-standard directories (like `tests/unit/`)
25+
very inconvenient (you would have to specify `-f tests/unit/*_test.yaml` on every invocation).
26+
So, we keep all of the unit test files under tests, but prefix them with `unit-` to separate them from
27+
the integration tests.
28+
29+
> Note! If you need to add unit tests, file names should follow this pattern: `tests/unit-name_your_test.yaml`
2530
2631
See https://github.com/quintush/helm-unittest/blob/master/DOCUMENT.md for details on writing unit tests.
2732

0 commit comments

Comments
 (0)