File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -93,17 +93,11 @@ const runDirect = wrap(processTask)
9393 . with ( secrets , { name : getSecretName } )
9494 . with ( helixStatus ) ;
9595
96- function isSqsEvent ( event , context ) {
97- if ( Array . isArray ( event ?. Records ) ) {
98- return true ;
99- }
100- if ( Array . isArray ( context ?. invocation ?. event ?. Records ) ) {
101- return true ;
102- }
103- return typeof event ?. type !== 'string' ;
96+ function isSqsEvent ( event ) {
97+ return Array . isArray ( event ?. Records ) ;
10498}
10599
106100export const main = async ( event , context ) => {
107- const handler = isSqsEvent ( event , context ) ? runSQS : runDirect ;
101+ const handler = isSqsEvent ( event ) ? runSQS : runDirect ;
108102 return handler ( event , context ) ;
109103} ;
Original file line number Diff line number Diff line change @@ -195,4 +195,25 @@ describe('Index Tests', () => {
195195 expect ( resp . status ) . to . equal ( 200 ) ;
196196 expect ( directContext . log . info . calledWith ( 'Found task handler for type: dummy' ) ) . to . be . true ;
197197 } ) ;
198+
199+ it ( 'treats direct invocation with context invocation records as direct' , async ( ) => {
200+ const directContext = {
201+ ...context ,
202+ invocation : {
203+ event : {
204+ Records : [ {
205+ body : JSON . stringify ( { fake : 'value' } ) ,
206+ } ] ,
207+ } ,
208+ } ,
209+ } ;
210+ const directEvent = {
211+ type : 'dummy' ,
212+ siteId : 'direct-site' ,
213+ } ;
214+
215+ const resp = await main ( directEvent , directContext ) ;
216+ expect ( resp . status ) . to . equal ( 200 ) ;
217+ expect ( directContext . log . info . calledWith ( 'Found task handler for type: dummy' ) ) . to . be . true ;
218+ } ) ;
198219} ) ;
You can’t perform that action at this time.
0 commit comments