Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mocking methods updating referenced structs #158

Merged
merged 1 commit into from
May 4, 2015

Commits on May 4, 2015

  1. Allow mocking methods updating referenced structs

    Some methods in Go take a pointer to a struct or a map and are supposed
    to set some values in the referenced argument. Using Return is not
    enough to mock such methods.
    
    We are introducing a Run method that allows setting a Call handler to
    make your mock update such referenced values.
    
    Example usage mocking a service that finds a user in a data store and
    fills the values in the provided struct:
    
    ```go
    m.On("Find", 1, mock.AnythingOfType(*User))
      .Return(nil)
      .Run(func(args mock.Arguments) {
      u := args.Get(0).(*User)
      u.ID = 1
      u.Email = "[email protected]"
    })
    ```
    ernesto-jimenez committed May 4, 2015
    Configuration menu
    Copy the full SHA
    a369d6f View commit details
    Browse the repository at this point in the history