@@ -156,38 +156,47 @@ describe('CloudEvents request to event function', () => {
156
156
headers : { [ key : string ] : string } ;
157
157
body : { } ;
158
158
}
159
+
160
+ const specversion = '1.0' ;
161
+ const type = 'com.google.cloud.storage' ;
162
+ const source =
163
+ 'https://github.com/GoogleCloudPlatform/functions-framework-nodejs' ;
164
+ const subject = 'test-subject' ;
165
+ const id = 'test-1234-1234' ;
166
+ const time = '2020-05-13T01:23:45Z' ;
167
+ const datacontenttype = 'application/json' ;
168
+ const data = {
169
+ some : 'payload' ,
170
+ } ;
171
+
159
172
const testData : TestData [ ] = [
160
173
{
161
- name : 'CloudEvents v0.2 structured content mode' ,
174
+ name : 'CloudEvents v1.0 structured content mode' ,
162
175
headers : { 'Content-Type' : 'application/cloudevents+json' } ,
163
176
body : {
164
- type : 'testType' ,
165
- specversion : 'testSpecversion' ,
166
- source : 'testSource' ,
167
- id : 'testId' ,
168
- time : 'testTime' ,
169
- schemaurl : 'testSchemaurl' ,
170
- contenttype : 'testContenttype' ,
171
- data : {
172
- some : 'payload' ,
173
- } ,
177
+ specversion,
178
+ type,
179
+ source,
180
+ subject,
181
+ id,
182
+ time,
183
+ datacontenttype,
184
+ data,
174
185
} ,
175
186
} ,
176
187
{
177
- name : 'CloudEvents v0.2 binary content mode' ,
188
+ name : 'CloudEvents v1.0 binary content mode' ,
178
189
headers : {
179
190
'Content-Type' : 'application/json' ,
180
- 'ce-type' : 'testType' ,
181
- 'ce-specversion' : 'testSpecversion' ,
182
- 'ce-source' : 'testSource' ,
183
- 'ce-id' : 'testId' ,
184
- 'ce-time' : 'testTime' ,
185
- 'ce-schemaurl' : 'testSchemaurl' ,
186
- 'ce-contenttype' : 'testContenttype' ,
187
- } ,
188
- body : {
189
- some : 'payload' ,
191
+ 'ce-specversion' : specversion ,
192
+ 'ce-type' : type ,
193
+ 'ce-source' : source ,
194
+ 'ce-subject' : subject ,
195
+ 'ce-id' : id ,
196
+ 'ce-time' : time ,
197
+ 'ce-datacontenttype' : datacontenttype ,
190
198
} ,
199
+ body : data ,
191
200
} ,
192
201
] ;
193
202
testData . forEach ( test => {
@@ -206,15 +215,15 @@ describe('CloudEvents request to event function', () => {
206
215
. set ( test . headers )
207
216
. send ( test . body )
208
217
. expect ( 204 ) ;
209
- assert . deepStrictEqual ( receivedData , { some : 'payload' } ) ;
218
+ assert . deepStrictEqual ( receivedData , data ) ;
210
219
assert . notStrictEqual ( receivedContext , null ) ;
211
- assert . strictEqual ( receivedContext ! . type , 'testType' ) ;
212
- assert . strictEqual ( receivedContext ! . specversion , 'testSpecversion' ) ;
213
- assert . strictEqual ( receivedContext ! . source , 'testSource' ) ;
214
- assert . strictEqual ( receivedContext ! . id , 'testId' ) ;
215
- assert . strictEqual ( receivedContext ! . time , 'testTime' ) ;
216
- assert . strictEqual ( receivedContext ! . schemaurl , 'testSchemaurl' ) ;
217
- assert . strictEqual ( receivedContext ! . contenttype , 'testContenttype' ) ;
220
+ assert . strictEqual ( receivedContext ! . specversion , specversion ) ;
221
+ assert . strictEqual ( receivedContext ! . type , type ) ;
222
+ assert . strictEqual ( receivedContext ! . source , source ) ;
223
+ assert . strictEqual ( receivedContext ! . subject , subject ) ;
224
+ assert . strictEqual ( receivedContext ! . id , id ) ;
225
+ assert . strictEqual ( receivedContext ! . time , time ) ;
226
+ assert . strictEqual ( receivedContext ! . datacontenttype , datacontenttype ) ;
218
227
} ) ;
219
228
} ) ;
220
229
} ) ;
0 commit comments