Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
gomock/controller: use skip additional frame
Browse files Browse the repository at this point in the history
In 8321731, the callerInfo call
gets nested within an additional function call, but the frame skip
isn't updated. When used with mockgen, this causes the location frame
to unhelpfully point to the generated mock instead of the callsite in
the user's test.

Before:
... at .../mocks/mock_ecriface/mock_ECRAPI.go:612 because: there are no expected calls of...

After:
... at .../example_test.go:29 because: there are no expected calls of...
  • Loading branch information
Stephen Wan authored and Stephen Wan committed Jun 5, 2020
1 parent 92f53b0 commit caa4408
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gomock/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (ctrl *Controller) Call(receiver interface{}, method string, args ...interf

expected, err := ctrl.expectedCalls.FindMatch(receiver, method, args)
if err != nil {
origin := callerInfo(2)
origin := callerInfo(3)
ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err)
}

Expand Down

0 comments on commit caa4408

Please sign in to comment.