kubewarden-controller
kubewarden-controller copied to clipboard
Increase the code coverage for the controllers package files to 70%
We have a goal to reach 70% of code coverage in the kubewarden controller repository. For that, we can improve the coverage of the controllers package. Considering the current metric of the package, it's virtually reached the 70%, the current coverage is 69.67%.
However, when we take a look on the individual files is possible to see that some of them need some improvement. The only two files under the 70% threshold is policyserver_controller.go (58.43%) and policystatus_utils.go (59.52%).
In the case of the policyserver_controller.go, most of the lines missing the coverage is the lines where errors are returned and requeue the reconciliation loop. I believe we can cover this line by doing some mocking and unit tests.
For the policystatus_utils.go file besides the lines returning when some error happen. There are some call to apimeta to set status conditions which are not being tested. I believe we can try to use some mock and unit tests to tests this lines as well.
Acceptance criteria
- [ ] Improve the
policyserver_controller.gocode coverage to reach close to 70% coverage - [ ] Improve the
policystatus_util.gotest to cover the missingSetStatusConditioncalls and reach close to 70% coverage
This is a spin off of #648
I think we should tackle https://github.com/kubewarden/kubewarden-controller/issues/660 before we go and improve the code coverage of the PolicyServer reconciliation loop. That's because there's quite some code we can delete once we address the linked issue