quintush / helm-unittest

BDD styled unit test framework for Kubernetes Helm charts as a Helm plugin.
MIT License
345 stars 69 forks source link

Check/count volumes (or even environment variables) that they don't exist #167

Closed dj-wasabi closed 1 year ago

dj-wasabi commented 2 years ago

Hi,

I have a helm template that based on a bool, a specific volume is added or not. I try to test this with a unit test but I don't get it to work.

I have tried this (only 1 volume instead of 2)

  - isNotEmpty:
      path: spec.template.spec.volumes[0]
  - isEmpty:
      path: spec.template.spec.volumes[1]

I also used contain, but then it complains about that I am comparing yaml which isn't supported. Based (on actually the same boolean) I add 2 environment variables. So if I set it to false, I dont want the volume and environment variables. And I want to test this.

So I am not sure how to continue with this. Any suggestions on how to resolve it?

rquinio1A commented 2 years ago

For arrays I think you have to use contains / notContains

quintush commented 1 year ago

@dj-wasabi, the issue is related to the processing of array Out Of Bounds processing.

In the new fix, the output will result in a null value.