Skip to content

Commit b41d6a9

Browse files
authored
Fix a bug in the CRE SDK standard test verifying calls are async, it allowed the first request to respond before the second was made (#1554)
* Fix a bug in the CRE SDK standard test verifying calls are async, it allowed the first request to respond before the second was made * Add comment
1 parent 8817bb8 commit b41d6a9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/workflows/wasm/host/standard_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func TestStandardErrors(t *testing.T) {
7373
}
7474

7575
func TestStandardCapabilityCallsAreAsync(t *testing.T) {
76+
// This test expects basic action's PerformAction to be called twice asynchronously and the results concatenated.
77+
// To ensure the calls are actually async, the mock will block the first call until the second call is made.
78+
// The first call sets InputThing to true, the second to false.
7679
t.Parallel()
7780
mockExecutionHelper := NewMockExecutionHelper(t)
7881
mockExecutionHelper.EXPECT().GetWorkflowExecutionID().Return("id")
@@ -98,12 +101,10 @@ func TestStandardCapabilityCallsAreAsync(t *testing.T) {
98101
require.NoError(t, err)
99102

100103
// Don't return until the second call has been executed
101-
defer func() {
102-
if !input.InputThing {
103-
mt.Lock()
104-
}
105-
defer mt.Unlock()
106-
}()
104+
if input.InputThing {
105+
mt.Lock()
106+
}
107+
defer mt.Unlock()
107108
return &sdk.CapabilityResponse{
108109
Response: &sdk.CapabilityResponse_Payload{Payload: payload},
109110
}, nil

0 commit comments

Comments
 (0)