kubewarden-controller icon indicating copy to clipboard operation
kubewarden-controller copied to clipboard

Increase the code coverage for the controllers package files to 70%

Open jvanz opened this issue 1 year ago • 2 comments

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.go code coverage to reach close to 70% coverage
  • [ ] Improve the policystatus_util.go test to cover the missing SetStatusCondition calls and reach close to 70% coverage

jvanz avatar Feb 29 '24 17:02 jvanz

This is a spin off of #648

jvanz avatar Mar 01 '24 11:03 jvanz

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

flavio avatar Mar 01 '24 15:03 flavio