I'm using testify for my unit tests and I have a mock structure created by mockery.
My interface looks like this:
type Foo interface {
Bar(...interface{})
}
Mockery creates the following struct using testify:
type Foo struct {
mock.Mock
}
// Error provides a mock function with given fields: v
func (_m *Foo) Bar(v ...interface{}) {
var _ca []interface{}
_ca = append(_ca, v...)
_m.Called(_ca...)
}
How can I use this mock struct passing an ellipsis argument to its functions?
Currently I am doing this:
mockFoo := &mocks.Foo{}
mockFoo.On("Bar", mock.Anything).Return()
But when I run my unit tests I get an error:
Error(string,*errors.errorString)
0: "Error sending message"
1: &errors.errorString{s:"error"}
The closest call I have is:
Error(string)
0: "mock.Anything"
Provided 1 arguments, mocked for 2 arguments
Diff: 0: PASS: (string=Error sending message) == (string=mock.Anything)
1: FAIL: (*errors.errorString=error) != (Missing)
How can I avoid this and call the On method using one or more arguments?