Skip to content
New issue

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

By clicking “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? Sign in to your account

Remove cache.OperatorCacheProvider interface. #2680

Conversation

benluddy
Copy link
Contributor

@benluddy benluddy commented Mar 2, 2022

This interface is unused, so it can be removed as a step toward a
stable and supported cache package API.

This interface is unused, so it can be removed as a step toward a
stable and supported cache package API.

Signed-off-by: Ben Luddy <bluddy@redhat.com>
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2022
@exdx
Copy link
Member

exdx commented Mar 2, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2022
Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

I have a question, but the answer won't impact my decision to merge at this point.

@@ -29,7 +29,7 @@ type constraintProvider interface {
}

type Resolver struct {
cache cache.OperatorCacheProvider
cache *cache.Cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would OperatorCacheProvider be useful for injecting mocks? or do you imagine further near-term refactoring to invalidate that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it were, I'd expect the interface to be defined by the consumer instead of exported from the cache package. I'm also not convinced that there will be a need to mock the cache. The contents of a cache are injectable, so tests are able to configure real objects that return what they want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it were, I'd expect the interface to be defined by the consumer instead of exported from the cache package.

I share that perspective. It should probably be defined in the resolver package (or even a Cache interface with the method signatures the resolver cares about).

The contents of a cache are injectable, so tests are able to configure real objects that return what they want.

My rule of thumb is to prefer abstracting with an interface (at the consumer, of course). I find that it helps to decouple the consumer tests from a particular implementation for two reasons:

  • It's usually easier to generate specific call outcomes without wrestling a real implementation to do so; for example, errors/bad data, a specific sequence occurring with a non-deterministic operation (e.g. map-key iteration), etc
  • Test-fixtures are usually smaller and more manageable

@openshift-ci
Copy link

openshift-ci bot commented Mar 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benluddy, njhale

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit ddf92b1 into operator-framework:master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants