title: How to mock for same input and different return values in a for loop in golang
body: <p>I'm running a test with multiple parameters in a for loop using go lang testing. </p>
  
  <p>I ran into a situation where same return value (and first set) is returned every time the mock is called. What I want to be able to do is change the return value for each test when the input is same i.e., same <code>On</code> but different <code>Return</code> in a loop. </p>
  
  <p>I am using stretchr/testify for mocks. It looks like it will not overwrite already created mock when <code>On</code> is same.</p>
  
  <pre><code>func TestUpdateContactWithNewActions(t *testing.T) {
      tests := []struct {
          testName  string
          getParams func() *activities.UpdateContactWithNewActionsActivity
          mockError error
      }{
  
          {"UpdateContactWithNewActions with error from contact service",
              func() *activities.UpdateContactWithNewActionsActivity {
                  return fixtures.GetUpdateContactWithNewActionsActivity()
              }, fixtures.Err},
          {"UpdateContactWithNewActions valid",
              func() *activities.UpdateContactWithNewActionsActivity {
                  return fixtures.GetUpdateContactWithNewActionsActivity()
              }, nil},
      }
  
      lib.LoadWithMockClients()
  
      for _, test := range tests {
          test := test
          t.Run(test.testName, func(t *testing.T) {
              lib.MockCSClient.On(
                  "UpdateContactWithNewActions",
                  mock.AnythingOfType("tchannel.headerCtx"),
                  fixtures.UpdateContactWithNewActions).Return(test.mockError)
  
              returnedResult, err := test.getParams().Execute(fixtures.Ctx)
              if test.mockError == nil {
                  // some assertion
              }
              assert.Error(t, err)
          })
      }
  }
  </code></pre>