quintush / helm-unittest

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

Contains assertion type doesn't support annotations map #107

Closed leanenkaa closed 3 years ago

leanenkaa commented 3 years ago

Hi, thank you for the useful plugin. It seems that contains assertion type doesn't support metadata.annotations map. Is this due to any limitations ?

quintush commented 3 years ago

Hello @leonenkoa,

The contains assertion is expecting an array. The map is technicaly not an array. That is why the contains is not working.

You can validate maps with the equal (which can handle complex structures), or validate if a specific map is available with IsNull.

I also will look on creating a containsMap assertion to validate if a specific map, with value is available.

Greetings, @quintush

gcavalcante8808 commented 3 years ago

Hey @quintush, do you have an example with isnull and a map assertion? I’m looking for it as well.

On Fri, 2 Apr 2021 at 13:48 Quintus @.***> wrote:

Hello @leonenkoa https://github.com/leonenkoa,

The contains assertion is expecting an array. The map is technicaly not an array. That is why the contains is not working.

You can validate maps with the equal (which can handle complex structures), or validate if a specific map is available with IsNull.

I also will look on creating a containsMap assertion to validate if a specific map, with value is available.

Greetings, @quintush https://github.com/quintush

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/quintush/helm-unittest/issues/107#issuecomment-812611671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE4PAKPJX35RMUJDI67VBDTGXYO3ANCNFSM42I3F2UQ .

quintush commented 3 years ago

Hello @gcavalcante8808 ,

As a quick answer, Take a look at the ingress tests. It will not have the IsNull, but it does show how to select a specific map.

Greetings, @quintush

quintush commented 3 years ago

Hello @gcavalcante8808,

I have created some examples with mappings. https://github.com/quintush/helm-unittest/blob/71544f7a30e97d280545da8cd5ba61b27d28f75c/test/data/v3/basic/tests/ingress_test.yaml#L72

Hopefully this will help.

Greetings, @quintush