Skip to content

Instantly share code, notes, and snippets.

@sanan-fataliyev
Created October 6, 2020 09:04
Show Gist options
  • Select an option

  • Save sanan-fataliyev/278c6e78cb642664af8f8c76aeabea82 to your computer and use it in GitHub Desktop.

Select an option

Save sanan-fataliyev/278c6e78cb642664af8f8c76aeabea82 to your computer and use it in GitHub Desktop.
testify helper method to set input argument
func argSetter(index int, newVal interface{}) func(args mock.Arguments) {
return func(args mock.Arguments) {
// get dest arg
dest := args.Get(index)
// inspect
ptr := reflect.ValueOf(dest)
// dereference
val := ptr.Elem()
// set value
val.Set(reflect.ValueOf(newVal))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment