@@ -298,6 +298,31 @@ func TestUnmarshal(t *testing.T) {
298
298
DataBase64 : true ,
299
299
},
300
300
},
301
+ "base64 json encoded data v1.0 - escaped json string" : {
302
+ body : []byte (`{
303
+ "specversion": "1.0",
304
+ "datacontenttype": "text/plain",
305
+ "data_base64": "\\u002B\\u002B\\u002B\\u002B",
306
+ "id": "ABC-123",
307
+ "time": "` + now .Format (time .RFC3339Nano ) + `",
308
+ "type": "com.example.test",
309
+ "dataschema": "http://example.com/schema",
310
+ "source": "http://example.com/source"
311
+ }` ),
312
+ want : & event.Event {
313
+ Context : event.EventContextV1 {
314
+ Type : "com.example.test" ,
315
+ Source : * sourceV1 ,
316
+ DataSchema : schemaV1 ,
317
+ ID : "ABC-123" ,
318
+ Time : & now ,
319
+ DataContentType : event .StringOfTextPlain (),
320
+ }.AsV1 (),
321
+ // base64 decode of "++++"
322
+ DataEncoded : []byte {0xfb , 0xef , 0xbe },
323
+ DataBase64 : true ,
324
+ },
325
+ },
301
326
"base64 xml encoded data v1.0" : {
302
327
body : mustJsonMarshal (t , map [string ]interface {}{
303
328
"specversion" : "1.0" ,
@@ -419,7 +444,9 @@ func TestUnmarshal(t *testing.T) {
419
444
t .Run (n , func (t * testing.T ) {
420
445
421
446
got := & event.Event {}
447
+ t .Logf ("tc.body: %s" , string (tc .body ))
422
448
err := json .Unmarshal (tc .body , got )
449
+ t .Logf ("Err: %s" , err )
423
450
424
451
if tc .wantErr != nil || err != nil {
425
452
if diff := cmp .Diff (tc .wantErr , err ); diff != "" {
0 commit comments