@@ -52,6 +52,11 @@ describe('WorkerChannel', () => {
5252 direction : 1 ,
5353 dataType : 1
5454 } ;
55+ const queueOutputBinding = {
56+ type : "queue" ,
57+ direction : 1 ,
58+ dataType : 1
59+ } ;
5560 const httpReturnBinding = {
5661 bindings : {
5762 req : httpInputBinding ,
@@ -64,6 +69,14 @@ describe('WorkerChannel', () => {
6469 res : httpOutputBinding
6570 }
6671 } ;
72+ const multipleBinding = {
73+ bindings : {
74+ req : httpInputBinding ,
75+ res : httpOutputBinding ,
76+ queueOutput : queueOutputBinding ,
77+ overriddenQueueOutput : queueOutputBinding
78+ }
79+ } ;
6780
6881 beforeEach ( ( ) => {
6982 stream = new TestEventStream ( ) ;
@@ -472,9 +485,63 @@ describe('WorkerChannel', () => {
472485 } ) ;
473486 } ) ;
474487
488+ it ( 'serializes multiple output bindings through context.done and context.bindings' , ( ) => {
489+ loader . getFunc . returns ( ( context ) => {
490+ context . bindings . queueOutput = "queue message" ;
491+ context . bindings . overriddenQueueOutput = "start message" ;
492+ context . done ( null , {
493+ res : { body : { hello : "world" } } ,
494+ overriddenQueueOutput : "override"
495+ } ) ;
496+ } ) ;
497+ loader . getInfo . returns ( new FunctionInfo ( multipleBinding ) ) ;
498+
499+ var actualInvocationRequest : rpc . IInvocationRequest = < rpc . IInvocationRequest > {
500+ functionId : 'id' ,
501+ invocationId : '1' ,
502+ inputData : [ httpInputData ] ,
503+ triggerMetadata : getTriggerDataMock ( ) ,
504+ } ;
505+
506+ stream . addTestMessage ( {
507+ invocationRequest : actualInvocationRequest
508+ } ) ;
509+
510+ sinon . assert . calledWithMatch ( stream . written , < rpc . IStreamingMessage > {
511+ invocationResponse : {
512+ invocationId : '1' ,
513+ result : {
514+ status : rpc . StatusResult . Status . Success
515+ } ,
516+ outputData : [ {
517+ data : {
518+ http : {
519+ body : { json : "{\"hello\":\"world\"}" } ,
520+ cookies : [ ] ,
521+ headers : { } ,
522+ statusCode : undefined
523+ }
524+ } ,
525+ name : "res"
526+ } ,
527+ {
528+ data : {
529+ string : "override"
530+ } ,
531+ name : "overriddenQueueOutput"
532+ } ,
533+ {
534+ data : {
535+ string : "queue message"
536+ } ,
537+ name : "queueOutput"
538+ } ]
539+ }
540+ } ) ;
541+ } ) ;
542+
475543 it ( 'serializes output binding data through context.done with V2 compat' , ( ) => {
476- let httpResponse ;
477- loader . getFunc . returns ( ( context ) => { httpResponse = context . res ; context . done ( null , { res : { body : { hello : "world" } } } ) } ) ;
544+ loader . getFunc . returns ( ( context ) => context . done ( null , { res : { body : { hello : "world" } } } ) ) ;
478545 loader . getInfo . returns ( new FunctionInfo ( httpResBinding ) ) ;
479546
480547 stream . addTestMessage ( {
@@ -503,12 +570,7 @@ describe('WorkerChannel', () => {
503570 result : {
504571 status : rpc . StatusResult . Status . Success
505572 } ,
506- outputData : [ {
507- data : {
508- http : httpResponse
509- } ,
510- name : "res"
511- } ] ,
573+ outputData : [ ] ,
512574 returnValue : {
513575 json : "{\"res\":{\"body\":{\"hello\":\"world\"}}}"
514576 }
0 commit comments