Skip to content

Unit testing support for Dependent Resources #1355

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
1 of 3 tasks
csviri opened this issue Jul 19, 2022 · 1 comment · Fixed by #1378
Closed
1 of 3 tasks

Unit testing support for Dependent Resources #1355

csviri opened this issue Jul 19, 2022 · 1 comment · Fixed by #1378
Milestone

Comments

@csviri
Copy link
Collaborator

csviri commented Jul 19, 2022

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:

#1175
#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 csviri added this to the 3.2 milestone Jul 19, 2022
@csviri csviri linked a pull request Jul 29, 2022 that will close this issue
@csviri csviri modified the milestones: 3.2, 3.3 Aug 30, 2022
@csviri csviri modified the milestones: 4.1, 4.2 Oct 28, 2022
@csviri csviri modified the milestones: 4.2, 4.3 Dec 12, 2022
@csviri
Copy link
Collaborator Author

csviri commented Jan 31, 2023

The problem here is that now dependent resources use also event source under the hood, (not to read the resource but to make sure some of the updates end up in the caches and similar tricks). It is quite hard to mock that all. But also conceptually, the framework tests dependent resources, so its kinda made sure those are tested. All the addition user does can be (desired state, matchers) tested separatettly by an unit test, what is trivial.

@csviri csviri closed this as completed Jan 31, 2023
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant