You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This, unfortunately, causes spurious missed expectation in the test case below. This is because the "2" is handed to the AdderRecorder as an int. This is Go's untyped int handling code choosing int instead of int64 as its default type since none is provided explicitly.
It looks plausible from the code to generate the Recorder methods with the right argument types and convert them down as the call method one does. (But maybe I haven't seen the bug that prevented that in the first place.)
One workaround is to just use the same variable in both places and another is to explicitly convert it to the right type, but it might nice for small tests to just make the right type.
type Thing struct { a Adder }
func (t Thing) CallsAdderInc(x int64) { t.a.Inc(x) }
func TestAdder(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
adder := NewMockAdder(ctrl)
myThing := Thing{adder}
adder.EXPECT().Inc(2).Return(nil) // This 2 is turned into int instead of int64
myThing.CallsAdderInc(2)
}