-
Notifications
You must be signed in to change notification settings - Fork 117
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
type-safe calls can't be used in gomock.InOrder #70
Labels
bug
Something isn't working
Comments
EstebanOlmedo
added a commit
that referenced
this issue
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 introduces a new interface called `WrapperCall` to support usage for this methods when typed flag is used. This interface helps to have compile-time error/warnings instead of runtime errors with a reflection based solution. Fixes (#70)
EstebanOlmedo
added a commit
that referenced
this issue
Sep 6, 2023
This modifies `InOrder` to receive variadic `any` instead of `*Call`, allowing users to use this function with type-safe generated Calls. This implementation uses a type assertion to check if the provided arguments are `*Call`s or reflection to get the `*Call` when the arguments wrap one (generated code). If neither of the two cases are fullfiled then that argument is ignored. Fix #70.
EstebanOlmedo
added a commit
that referenced
this issue
Sep 7, 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)
sywhang
added a commit
that referenced
this issue
Sep 13, 2023
This modifies `InOrder` to receive variadic `any` instead of `*Call`, allowing users to use this function with type-safe generated Calls. This implementation uses a type assertion to check if the provided arguments are `*Call`s or reflection to get the `*Call` when the arguments wrap one (generated code). If neither of the two cases are fullfiled then `InOrder` panics. Fix #70. --------- Co-authored-by: Sung Yoon Whang <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actual behavior When using type-safe mode (
-typed
), the calls returned fromEXPECT().Method()
are typed. This is great, and a feature I've been waiting for for a long time. However, it makes it impossible to use them ingomock.InOrder
, sinceInOrder
expects a*gomock.Call
.Expected behavior I expected
gomock.InOrder
to work seamlessly.To Reproduce Steps to reproduce the behavior
-typed
gomock.InOrder
with calls of that mockAdditional Information
Triage Notes for the Maintainers
Failed CI run on quic-go after generating typed mocks: https://github.com/quic-go/quic-go/actions/runs/5988902088/job/16244553880?pr=4051 (PR: quic-go/quic-go#4051)
The text was updated successfully, but these errors were encountered: