@@ -211,6 +211,43 @@ describe('Event Function', () => {
211211 } ) ;
212212 } ) ;
213213
214+ it ( 'marshals attribute-only Pub/Sub emulator requests' , async ( ) => {
215+ let receivedData : { } | null = null ;
216+ let receivedContext : functions . CloudFunctionsContext | null = null ;
217+ const server = getServer ( ( data : { } , context : functions . Context ) => {
218+ receivedData = data ;
219+ receivedContext = context as functions . CloudFunctionsContext ;
220+ } , testOptions ) ;
221+
222+ await supertest ( server )
223+ . post ( '/projects/FOO/topics/BAR_TOPIC' )
224+ . send ( {
225+ subscription : 'projects/FOO/subscriptions/BAR_SUB' ,
226+ message : {
227+ messageId : 'attribute-only-message' ,
228+ publishTime : '2026-07-22T00:00:00.000Z' ,
229+ attributes : { attribute1 : 'value1' } ,
230+ } ,
231+ } )
232+ . set ( { 'Content-Type' : 'application/json' } )
233+ . expect ( 204 ) ;
234+
235+ assert . deepStrictEqual ( receivedData , {
236+ '@type' : 'type.googleapis.com/google.pubsub.v1.PubsubMessage' ,
237+ attributes : { attribute1 : 'value1' } ,
238+ } ) ;
239+ assert . deepStrictEqual ( receivedContext , {
240+ eventId : 'attribute-only-message' ,
241+ timestamp : '2026-07-22T00:00:00.000Z' ,
242+ eventType : 'google.pubsub.topic.publish' ,
243+ resource : {
244+ service : 'pubsub.googleapis.com' ,
245+ type : 'type.googleapis.com/google.pubsub.v1.PubsubMessage' ,
246+ name : 'projects/FOO/topics/BAR_TOPIC' ,
247+ } ,
248+ } ) ;
249+ } ) ;
250+
214251 it ( 'returns a 500 if the function throws an exception' , async ( ) => {
215252 const server = getServer ( ( ) => {
216253 throw 'I crashed' ;
0 commit comments