quintush / helm-unittest

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

[request] Allow templates to be selected via wildcard #173

Closed 0xStarcat closed 1 year ago

0xStarcat commented 2 years ago

Hey! I really love this plugin. I had a request that I think would be a nice feature to add for testing scenarios like the one I'm encountering.

Say your team's pattern is to separate configMaps into their own files:

templates/
  configMaps/
    - config1.yaml
    - config2.yaml
    - config3.yaml

And say you want to run a test on all of them plus any future files that get added to the templates/configMaps directory. At present, the test requires you to manually add a new template entry to the list each time.

suite: test configmaps
templates: # if only we could do config-maps/*.yaml
  - configMaps/config1.yaml
  - configMaps/config2.yaml
  - configMaps/config3.yaml
tests:
  - it: does NOT render in prod
    values:
      - ../values.yaml
    asserts:
      - hasDocuments:
          count: 0
  - it: renders in QA
    values:
      - ../values.yaml
      - ../values.qa.yaml
    asserts:
      - hasDocuments:
          count: 1

It would be really useful if this test just could "discover" any yaml files inside of the directory without needing you to explicitly add them to the test. Like so:

suite: test configmaps
templates: 
  - configMaps/*.yaml

or maybe

suite: test configmaps
templatesSubDir: configMaps
quintush commented 1 year ago

Hello @0xStarcat,

It is indeed a good idea. I will look into it.

Greetings, @quintush

neogopher commented 1 year ago

Hi @quintush .

Just wanted to know whether have you been working on this one. We are interested in a similar functionality. Actually, we desire to have a global wildcard (*) and that would glob all the templates under the templates directory. We can then use it with snapshot testing to match the snapshots under different scenarios.