Mocked API calls in an activity

I’m trying to figure out an idiomatic way of testing a workflow where an activity calls out to an external API. My thought is to pass the api client into the activity as an arg and then pass a mocked client for testing. However, its not clear to me how to get my mock into the activity from the test.

I’d like to test the whole workflow with a mocked client something like

func (s *UnitTestSuite) Test_Workflow() {
c := &API{
Operations: &s.mock,
}
s.mock.On(“CallFoo”, mock.Anything).Return(
&operations.CallFoo{
Payload: &CallFooResponse{Result: “1234”},
})

s.env.ExecuteWorkflow(SomeWorkflow, Input{something: "123"})
s.True(s.env.IsWorkflowCompleted())
s.NoError(s.env.GetWorkflowError())

}

I can’t pass the client via ExecuteWorkflow since its not serializable. The workflow could pass the client to the activity but then that would bleed testing logic into the app. It feels like i’m missing something obvious here. any pointers?

I figured this out. I’m using a struct with the activities as methods… I just need to construct the struct with the mocked client. I had this initially but was getting nil pointers. Somewhere a long the line I’d overwritten my struct with the mocked interface.