Skip to content

Unit testing support for Dependent Resources #1355

Closed

Description

@csviri

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

Activity

  1. added this to the 3.2 milestone on Jul 19, 2022
  2. modified the milestones: 3.2, 3.3 on Aug 30, 2022
  3. modified the milestones: 4.1, 4.2 on Oct 28, 2022
  4. modified the milestones: 4.2, 4.3 on Dec 12, 2022
  5. csviri commented on Jan 31, 2023

    @csviri
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions