crossplane-runtime icon indicating copy to clipboard operation
crossplane-runtime copied to clipboard

Mock for resource.ClientApplicator

Open muvaf opened this issue 5 years ago • 2 comments

What problem are you facing?

Currently, we're able to use fake.MockClient and its functions to mock the controller-runtime client. However, there is no mock ClientApplicator, which makes it hard to replace Apply with a function that returns given error.

How could Crossplane help solve your problem?

Expand MockClient or implement a MockClientApplicator.

muvaf avatar May 08 '20 01:05 muvaf

iirc ClientApplicator is a struct that embeds the Client and Applicator interfaces, so I usually just write something like:

ca := resource.ClientApplicator{
    Client: &test.MockClient{
        MockGetFn: func(...) error { return nil }
    },
    Applicator: resource.ApplyFn(func(...) error { return nil }),
}

Would a mock make this much easier? I imagine you'd end up needing about the same amount of typing to get it all setup.

negz avatar May 08 '20 23:05 negz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 07:08 stale[bot]

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

github-actions[bot] avatar Sep 05 '24 01:09 github-actions[bot]