java-operator-sdk icon indicating copy to clipboard operation
java-operator-sdk copied to clipboard

Unit testing support for Dependent Resources

Open csviri opened this issue 3 years ago • 0 comments

Support for unit testing (mocking) should be improved for dependent resources. Currently for example for CRUDKubernetesDependentResource is calling eventsource().getSecondaryResource to load the actual state from cache. Eventually this as described on other issues:

https://github.com/java-operator-sdk/java-operator-sdk/issues/1175 https://github.com/java-operator-sdk/java-operator-sdk/issues/1240

might be better to call context.getSecondaryResource().

With this we could actually make it easy to support cache state for unit tests.

But we should also create examples, and support for client mocking.

Acceptance Criteria:

  • [ ] Can developers easily mock context.getSecondaryResource (assumption is used in dependent resources - but useful in general)
  • [ ] Can developers easily mock Kubernetes Client for other operations.
  • [ ] Is there a example showcasing unit testing

csviri avatar Jul 19 '22 12:07 csviri