kapicorp / kapitan

Generic templated configuration management for Kubernetes, Terraform and other things
https://kapitan.dev
Apache License 2.0
1.8k stars 198 forks source link

[feat]: Add testing bootstrap code for templates #1112

Open uberspot opened 8 months ago

uberspot commented 8 months ago

Description of the feature

Hey legends! :)

We were using kapitan and got a request from some devs writing templates in it for a nice/quick way of testing template code. Testing functionality is easy with a test target for example, but testing cases that should fail is trickier if you want kapitan compile to still compile all targets. Is anyone else doing something similar? Otherwise it sounds like a feature we could add to kapitan to e.g. call pytest if a flag is passed before compiling but after creating the inventory internally (?).

Additional context

No response

MatteoVoges commented 7 months ago

We could also add a flag in the target allow_failure, so that the target doesn't require to compile. Then you would need to check for your expected result (compiled or not) afterwards.

Embedding pytest or another test framework would need much more library support, which includes interfaces, modularity and API interface instead of setting the argvector and calling main()