Go-sdk: test setup - simulating a failed response from a `GetChildWorkflowExecution` call

Hi there,
I am writing a test to simulate error handling for a failed call to GetChildWorkflowExecution. Looking for how to mock this behavior in the test.

In the parent workflow, I am triggering an ExecuteChildWorkflow call to a second workflow. It is a long running workflow, so I am using GetChildWorkflowExecution to validate that the child workflow was successfully started before continuing on in the parent workflow.

I would like to test the error handling when this child workflow does not start successfully.

I have this child workflow registered in the test suite and am trying to use an s.env.onWorkflow helper to mock it out. Is there something I can to with s.env.onWorkflow (or some other way) to simulate a failed response from the GetChildWorkflowExecution call?


From internal package - go.temporal.io/sdk/internal - pkg.go.dev

You could also setup mock to simulate start child workflow failure case by returning ErrMockStartChildWorkflowFailed as error.

Awesome, thanks Chad.
This looks like what I need.

Do you have an example of this working?

I was able to access the ErrMockStartChildWorkflowFailed on the internal package, but from what I understand you’re not supposed to use the internal pacakge directly (also it breaks the tests).

	s.env.OnWorkflow(someWorkflow, mock.Anything, mock.Anything,

The only other example I see in the wild is this cadence example, but no idea how this value is getting imported into the package scope


This is exposed at testsuite package - go.temporal.io/sdk/testsuite - pkg.go.dev. So you’d use testsuite.ErrMockStartChildWorkflowFailed.

Awesome! Got it working.
Thanks so much for the quick feedback.