diff --git a/pkg/workflows/wasm/host/standard_test.go b/pkg/workflows/wasm/host/standard_test.go index 69cf8a6ee..253864273 100644 --- a/pkg/workflows/wasm/host/standard_test.go +++ b/pkg/workflows/wasm/host/standard_test.go @@ -73,6 +73,9 @@ func TestStandardErrors(t *testing.T) { } func TestStandardCapabilityCallsAreAsync(t *testing.T) { + // This test expects basic action's PerformAction to be called twice asynchronously and the results concatenated. + // To ensure the calls are actually async, the mock will block the first call until the second call is made. + // The first call sets InputThing to true, the second to false. t.Parallel() mockExecutionHelper := NewMockExecutionHelper(t) mockExecutionHelper.EXPECT().GetWorkflowExecutionID().Return("id") @@ -98,12 +101,10 @@ func TestStandardCapabilityCallsAreAsync(t *testing.T) { require.NoError(t, err) // Don't return until the second call has been executed - defer func() { - if !input.InputThing { - mt.Lock() - } - defer mt.Unlock() - }() + if input.InputThing { + mt.Lock() + } + defer mt.Unlock() return &sdk.CapabilityResponse{ Response: &sdk.CapabilityResponse_Payload{Payload: payload}, }, nil