title: testify using real function result as mocked function argument
body: <p>How can I test this function<br />
  I need to make sure mocked FindByID function return value is a user with created UUID.</p>
  <pre class="lang-golang prettyprint-override"><code>func (s *Service) Register(newUser domain.User) (domain.User, error) {
      newUser.ID = uuid.New()
      s.repo.Create(newUser)
      createdUser, err := s.FindByID(newUser.ID)
      if err != nil {
          return domain.User{}, err
      }
      return createdUser, nil
  }
  </code></pre>
  <p>Currently test function</p>
  <pre class="lang-golang prettyprint-override"><code>t.Run(&quot;When Register called, it should return createdUser&quot;, func(t *testing.T) {
          repo := new(mocks.UserRepository)
          s := service.NewService(repo)
          user := domain.User{Name: &quot;TestName&quot;, Email: &quot;TestEmail&quot;}
  
          repo.On(&quot;Create&quot;, mock.Anything)
          // I need to make sure FindByID function return value is a user with created UUID
          repo.On(&quot;FindByID&quot;, mock.Anything).Return(user, nil)
  
          createdUser, err := s.Register(user)
  
          assert.NoError(t, err)
          assert.IsType(t, createdUser.ID, uuid.UUID{})
      })
  </code></pre>