#GoMock - Mock function should assign outside scope var value ( not return )

3 messages · Page 1 of 1 (latest)

valid sapphire
#

GoMock - Mock function should assign outside scope var value ( not return )

weak plaza
#

are you trying to do a var type function that has an enter argument type function ?

torn sequoia
#

You have to use a pointer and „do” function on mock, sth like that:

var myString string
mock.On(„method”, str).Do(func(args interface{}) {
*(&myString) = args.Get(0).(string)
}).Return(myString).Once()

Sorry for not being specific, I’m typing this from my mobile, if you won’t manage to get it working I’ll find a working solution for you later on