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?