WIP: Introduce bash scripting unittests #724

Draft
justusbunsi wants to merge 12 commits from justusbunsi/bats-shell-testing into main
justusbunsi commented 2024-11-10 23:08:47 +00:00 (Migrated from gitea.com)

Description of the change

This adds an environment for unit testing our bash scripts, using BATS.
It implements first tests for config_environment.sh.

Benefits

Writing unit tests for bash scripts documents the expected behavior and allows it being a quality gate in our CI.

Possible drawbacks

Not everyone is familiar with this approach and unit testing framework. Me neither, it took me some hours to get into it.

Applicable issues

  • Related to #691 where an issue in config_environment.sh was detected. It doesn't fixes it yet. This will be a dedicated Pull Request.

Additional information

I had to extract the bash script into an actual .sh file. Therefore, the token.sh script from the act_runner Pull Request had to be moved into its own subfolder.
To better distinguish between Helm unittests and Bash unittests, all Helm unittests are moved into their own subfolder.

💡 Since the diff is very large, reviewing each commit might be better. I made atomic commits.

### Description of the change This adds an environment for unit testing our bash scripts, using [BATS](https://github.com/bats-core/bats-core). It implements first tests for `config_environment.sh`. ### Benefits Writing unit tests for bash scripts documents the expected behavior and allows it being a quality gate in our CI. ### Possible drawbacks Not everyone is familiar with this approach and unit testing framework. Me neither, it took me some hours to get into it. ### Applicable issues - Related to #691 where an issue in `config_environment.sh` was detected. It doesn't fixes it yet. This will be a dedicated Pull Request. ### Additional information I had to extract the bash script into an actual `.sh` file. Therefore, the `token.sh` script from the act_runner Pull Request had to be moved into its own subfolder. To better distinguish between Helm unittests and Bash unittests, all Helm unittests are moved into their own subfolder. 💡 **Since the diff is very large, reviewing each commit might be better. I made atomic commits.**
justusbunsi commented 2024-11-10 23:22:04 +00:00 (Migrated from gitea.com)

🤔 Making the tests pass in the CI is something for another day...

🤔 Making the tests pass in the CI is something for another day...
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin justusbunsi/bats-shell-testing:justusbunsi/bats-shell-testing
git checkout justusbunsi/bats-shell-testing
Sign in to join this conversation.