@@ -118,6 +118,37 @@ func TestStandardCapabilityCallsAreAsync(t *testing.T) {
118118 assert .Equal (t , "truefalse" , result )
119119}
120120
121+ func TestStandardHostWasmWriteErrorsAreRespected (t * testing.T ) {
122+ t .Parallel ()
123+ mockExecutionHelper := NewMockExecutionHelper (t )
124+ mockExecutionHelper .EXPECT ().GetNodeTime ().RunAndReturn (func () time.Time {
125+ return time .Now ()
126+ }).Maybe ()
127+ mockExecutionHelper .EXPECT ().GetWorkflowExecutionID ().Return ("id" )
128+ mockExecutionHelper .EXPECT ().CallCapability (mock .Anything , mock .Anything ).RunAndReturn (func (ctx context.Context , request * sdk.CapabilityRequest ) (* sdk.CapabilityResponse , error ) {
129+ // In this test the response from the capability is successful,
130+ // but the WASM didn't provide a large enough buffer to fit it
131+ // 500 MB will suffice for the overflow on writes.
132+
133+ tooLargeResponse := make ([]byte , 500000000 )
134+
135+ // Since the bytes in the payload shouldn't be read, we don't need a valid proto
136+ payload := & anypb.Any {
137+ TypeUrl : "fake" ,
138+ Value : tooLargeResponse ,
139+ }
140+
141+ return & sdk.CapabilityResponse {Response : & sdk.CapabilityResponse_Payload {Payload : payload }}, nil
142+ })
143+
144+ m := makeTestModule (t )
145+ request := triggerExecuteRequest (t , 0 , & basictrigger.Outputs {CoolOutput : anyTestTriggerValue })
146+ errStr := executeWithError (t , m , request , mockExecutionHelper )
147+
148+ // Use Contains instead of Equal for flexibility, as languages have different conventions for errors.
149+ require .Contains (t , errStr , ResponseBufferTooSmall )
150+ }
151+
121152func TestStandardModeSwitch (t * testing.T ) {
122153 t .Parallel ()
123154 t .Run ("successful mode switch" , func (t * testing.T ) {
0 commit comments