Closed alvalea closed 8 years ago
Numeric types in Go are distinct types. An int
is not the same as a uint64
. When your test writes mockObj.EXPECT().SomeMethod(1, "second")
then the 1
becomes a int
(since the expectation methods take interface{}
args to support matchers), and int(1)
is not uint64(1)
.
Write mockObj.EXPECT().SomeMethod(uint64(1), "second")
instead and it should work fine.
Ok, thank you very much
Why do not generate mock that expects int64 instead of interface{} ? It should be easy, because you already generates real types for Mock object, but not for MockRecorder. Is there any reason you could not allow int64 and other specific types? It could be a flag for mockgen finally.
@melkus Because you can use gomock.Any()
or similar constructs instead of concrete values when declaring expectations
Mocking a method with int and string parameters generates a mock that does not expect those types. However, if both parameters are of type string, it works properly.
output
lib.go
lib_test.go
mockgen