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

Mock for functions #205

Open
tulzke opened this issue Sep 24, 2024 · 0 comments
Open

Mock for functions #205

tulzke opened this issue Sep 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@tulzke
Copy link
Contributor

tulzke commented Sep 24, 2024

We need the ability to create mocks for functions, not just for interfaces.
It can be usually in cases, where we use callback functions.
Example:

type RunFunc func(ctx context.Context) error

type Runner struct {
  // ...
  run RunFunc // cannot mock this function now
}

I don't want to use interface here, because it imposes a restriction on the name of the method. All I need is a contract match.

Feature request from old gomock: golang/mock#519

Same feature is available in mockery now

@JacobOaks JacobOaks added the enhancement New feature or request label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants