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

Support type-safe InOrder and After #77

Closed
wants to merge 2 commits into from

Conversation

EstebanOlmedo
Copy link
Collaborator

@EstebanOlmedo EstebanOlmedo commented Sep 5, 2023

Currently when type-safe return values are used, one can't use
InOrder neither After with them as they expect
*gomock.Call as parameters. This changes the type these functions
expect to be an interface which implements the GetCall() *Call method,
which returns the embedded *gomock.Call type for generated mock types.

Using this approach helps to have compile-time error/warnings instead of
runtime errors with a reflection based solution.

Fixes (#70)

gomock/call.go Outdated Show resolved Hide resolved
gomock/call.go Outdated Show resolved Hide resolved
Currently when type-safe return values are used, one can't use
`InOrder` neither `After` with them as they expect
`*gomock.Call` as parameters. This changes the type these functions
expect to be an interface which implements the `GetCall() *Call` method,
which returns the embedded `*gomock.Call` type for generated mock types.

Using this approach helps to have compile-time error/warnings instead of
runtime errors with a reflection based solution.

Fixes (#70)
@EstebanOlmedo EstebanOlmedo changed the title Add wrapper interface for gomock.Call Support type-safe InOrder and After Sep 7, 2023
marten-seemann added a commit to quic-go/quic-go that referenced this pull request Sep 11, 2023
marten-seemann added a commit to quic-go/quic-go that referenced this pull request Sep 11, 2023
marten-seemann added a commit to quic-go/quic-go that referenced this pull request Sep 11, 2023
marten-seemann added a commit to quic-go/quic-go that referenced this pull request Sep 11, 2023
marten-seemann added a commit to quic-go/quic-go that referenced this pull request Sep 11, 2023
Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

I tried this PR out in quic-go/quic-go#4057 and it seems to work (CI failures are due to #80 and #81, which are unrelated to this PR).

gomock/call.go Outdated Show resolved Hide resolved
Add a new exported interface `CallWrapper` which allow users to use
`InOrder` and `After` with generated type-safe mock types.
@sywhang
Copy link
Contributor

sywhang commented Sep 12, 2023

Let's go with the approach #78 instead.

The addition of this CallWrapper interface is undesirable, when it's not necessary to add this.

@marten-seemann could you try with #78 instead?

@sywhang sywhang closed this Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants