Repository navigation
Upgrade helm-unittest #414
Description
The primary upstream for helm-unittest has moved from quintush/helm-unittest to helm-unittest/helm-unittest.
So, we need to update these lines to refer to the helm-unittest org:
stackstorm-k8s/tests/README.md
Line 7 in ef1ed63
| Unit tests (`tests/unit/*_test.yaml`) use [`helm-unittest`](https://github.com/quintush/helm-unittest). |
stackstorm-k8s/tests/README.md
Line 14 in ef1ed63
| helm plugin install https://github.com/quintush/helm-unittest |
stackstorm-k8s/tests/README.md
Line 25 in ef1ed63
| See https://github.com/quintush/helm-unittest/blob/master/DOCUMENT.md for details on writing unit tests. |
| helm plugin install https://github.com/quintush/helm-unittest --version v0.2.11 |
And then we need to upgrade the version from v0.2.11 to a newer release. It looks like 0.4.4 is the latest as of 11 April 2024.
https://github.com/helm-unittest/helm-unittest/releases
There are several features in newer versions that look like they would allow us to simplify some of our tests, or make it possible to actually test things like the init containers. For example, v0.3.0 added jsonpath support. I hope that means we could replace the documentIndex with something that looks up the document based on something else, like the resource name. In any case, we should update the version of helm-unittest as much as possible, and then we can refactor the test in follow-up PRs.
Related to:
Activity
jk464 commentedon May 8, 2024
I installed the latest verison and gave it a test:
It bailed immediately on
overrides_testDeleting that one test, it will actual run the rest, but gets a bunch of errors:
jk464 commentedon May 8, 2024
Ok first issue is
0.3.0addedjsonPath(https://github.com/helm-unittest/helm-unittest/blob/main/CHANGELOG.md#030--2023-01-30) which requires updating ourpathreferences tojqstyle ones:jk464 commentedon May 8, 2024
There also seems to be a bug in
v0.5.0thats causing the theno assertsissue - helm-unittest/helm-unittest#329 - so I guess I'll just target0.4.4for now...jk464 commentedon May 8, 2024
Fixing the
jsonPathand running on v0.4.4 and all, but one, checks work:Seems the logic
isNullwas changed, such that if the path exists but has an empty value, i.e.This is no longer
null(as the functionisNullwas refactored and renamednotExists- instead you should useisNullOrEmpty- which expects that path to exist but be empty or "null" - which seems to be a confusing double meaning use ofnullhere!Either way, having this:
Seems silly as you end up with ugly unset keys hanging around, so changing all instances of that too:
Is cleaner looking, and also means the test once again passes ;)
jk464 commentedon May 8, 2024
Replacing instances of:
isNotNullwithexistsisNullwithnotExistsisEmptywithisNullOrEmptyisNotEmptywithisNotNullOrEmptyIsn't required, but doing so as it seems the old functions are "deprecated" as of https://github.com/helm-unittest/helm-unittest/blob/main/CHANGELOG.md#032--2023-04-17, and the new names better describe their function anyway, and with that all tests pass on
v0.4.4Furthermore, removing the tests impacted by the bug in
v0.5.0and trying, all those tests also pass!So i'll get a PR open now w/ the changes to support
v0.4.4and once the bug is patched inv0.5.0we should be able to just bump straight tov0.5.x@cognifloydRefactor unit tests to support unittests v0.4.4
jk464 commentedon May 8, 2024
@cognifloyd See #417 which should resolve this :)
Refactor unit tests to support unittests v0.4.4
Refactor unit tests to support unittests v0.4.4
Refactor unit tests to support unittests v0.4.4 (#417)
docs: update helm-unittest references and tests README (Closes StackS…