-
Notifications
You must be signed in to change notification settings - Fork 6
WIP: use helm-unittest to add unit test for helm tpl test #112
Conversation
DexterYan
commented
Jul 28, 2023
•
edited
Loading
edited
- https://github.com/helm-unittest/helm-unittest is quite good frame work to do unit test for helm
@DexterYan the main issue I saw with helm-unittest is how it expects to find objects: https://github.com/helm-unittest/helm-unittest/blob/main/DOCUMENT.md#test-job The framework assumes a single document is generated from a single template. If that's not true, it falls back to letting you select from an index. With how the library chart works, generate all objects from a single template, which means the user would have to write all tests against document indexes selecting the document number for each test. This would be very brittle and difficult to refactor. Any change that added new objects could potentially break every existing test requiring new indexes be updated for each. I am also a little concerned about the coverage for writing tests in this way. For example airflow used this and migrated off after finding it difficult to use (apache/airflow#11657 (comment)). In particular this user states you can't assert that something is not created, which is something I have a PR for right now #113 that needs to verify when you specify an existingClaim one is not generated. That was several years ago, so possibly it's improved but I wanted to see if you've already considered this drawbacks. |
I have added the multiple service accounts tests. However, there is a bug for the current testing
if you not define the The issue is caused by https://github.com/helm-unittest/helm-unittest/blob/14210a3f1db6fe59b7a39fae6ffab5c83dbbcb4d/pkg/unittest/validators/equal_validator.go#L49, this function is using continue and looping the append the validateError, and the last error is also appended. Should be a easy fix. For your concern about document number for indexing, I think it is possible to use They also did sort to ensure consistent index, https://github.com/helm-unittest/helm-unittest/blob/14210a3f1db6fe59b7a39fae6ffab5c83dbbcb4d/pkg/unittest/assertion.go#L43C34-L43C34. |
I'm not sure why you're calling this a bug, this is as far as I can tell from the product documentation by design. The documentIndex is required if you have more than one document. I honestly don't see how we can proceed with this approach as long as the documentIndex is how multi docs are defined. If you think there's a way to address that's what you should be demonstrating. If that can't be done I don't think the rest of this matters.
Strike this part, that's 17ms not 17s Is there a reason you're leaning toward this method over terratest? I see a lot of red flags with this approach currently. |