Skip to content

Commit c0af8bf

Browse files
authored
Merge branch 'main' into PLEX-1878
2 parents 802bc46 + ab2f6ce commit c0af8bf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/workflows/wasm/host/standard_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@ func TestStandardCapabilityCallsAreAsync(t *testing.T) {
9595
assert.Equal(t, "PerformAction", request.Method)
9696
input := &basicaction.Inputs{}
9797
assert.NoError(t, request.Payload.UnmarshalTo(input))
98-
assert.False(t, callsSeen[input.InputThing])
99-
callsSeen[input.InputThing] = true
100-
payload, err := anypb.New(&basicaction.Outputs{AdaptedThing: fmt.Sprintf("%t", input.InputThing)})
101-
require.NoError(t, err)
10298

10399
// Don't return until the second call has been executed
100+
// Take the lock before accessing callsSeen to avoid a race
104101
if input.InputThing {
105102
mt.Lock()
106103
}
107104
defer mt.Unlock()
105+
106+
assert.False(t, callsSeen[input.InputThing])
107+
callsSeen[input.InputThing] = true
108+
payload, err := anypb.New(&basicaction.Outputs{AdaptedThing: fmt.Sprintf("%t", input.InputThing)})
109+
require.NoError(t, err)
110+
108111
return &sdk.CapabilityResponse{
109112
Response: &sdk.CapabilityResponse_Payload{Payload: payload},
110113
}, nil

0 commit comments

Comments
 (0)