Open patrick246 opened 3 years ago
you can ignore the parameter's name at all in the interfaces:
package test
//go:generate mockery --name Test
type Test interface {
Test(int)
}
it generates this code:
// Code generated by mockery v2.9.4. DO NOT EDIT.
package mocks
import mock "github.com/stretchr/testify/mock"
// Test is an autogenerated mock type for the Test type
type Test struct {
mock.Mock
}
// Test provides a mock function with given fields: _a0
func (_m *Test) Test(_a0 int) {
_m.Called(_a0)
}
Observed behavior
When generating mocks for an interface like this
the generated code looks like this
The problem here is, that the call
_m.Called(_)
uses the_
like an actual variable.Expected behavior
I expected the generated code to look like this
that is, to replace the invalid parameter name with an autogenerated value.
Workaround
Of course, this is solved by giving the parameter in the interface an actual name. However, I think that valid Go code should not cause mockery to generate invalid Go code.