@@ -377,6 +377,65 @@ SENTRY_TEST(write_raw_envelope_to_file)
377377 sentry_close ();
378378}
379379
380+ SENTRY_TEST (raw_envelope_event_id )
381+ {
382+ sentry_envelope_t * envelope = create_test_envelope ();
383+ const char * test_file_str = SENTRY_TEST_PATH_PREFIX "sentry_test_envelope" ;
384+ sentry_path_t * test_file_path = sentry__path_from_str (test_file_str );
385+ TEST_CHECK_INT_EQUAL (
386+ sentry_envelope_write_to_file (envelope , test_file_str ), 0 );
387+
388+ sentry_envelope_t * raw_envelope
389+ = sentry__envelope_from_path (test_file_path );
390+ TEST_CHECK (!!raw_envelope );
391+
392+ sentry_uuid_t event_id = sentry__envelope_get_event_id (raw_envelope );
393+ char event_id_str [37 ];
394+ sentry_uuid_as_string (& event_id , event_id_str );
395+ TEST_CHECK_STRING_EQUAL (
396+ event_id_str , "c993afb6-b4ac-48a6-b61b-2558e601d65d" );
397+
398+ sentry__path_remove (test_file_path );
399+ sentry__path_free (test_file_path );
400+ sentry_envelope_free (envelope );
401+ sentry_envelope_free (raw_envelope );
402+
403+ // missing event_id
404+ const char header_no_event_id []
405+ = "{\"dsn\":\"https://foo@sentry.invalid/42\"}\n{}" ;
406+ test_file_path = sentry__path_from_str (test_file_str );
407+ TEST_CHECK_INT_EQUAL (
408+ sentry__path_write_buffer (
409+ test_file_path , header_no_event_id , sizeof (header_no_event_id ) - 1 ),
410+ 0 );
411+ raw_envelope = sentry__envelope_from_path (test_file_path );
412+ TEST_CHECK (!!raw_envelope );
413+ event_id = sentry__envelope_get_event_id (raw_envelope );
414+ TEST_CHECK (sentry_uuid_is_nil (& event_id ));
415+ sentry__path_remove (test_file_path );
416+ sentry__path_free (test_file_path );
417+ sentry_envelope_free (raw_envelope );
418+
419+ // missing newline
420+ const char header_no_newline []
421+ = "{\"event_id\":\"c993afb6-b4ac-48a6-b61b-2558e601d65d\"}" ;
422+ test_file_path = sentry__path_from_str (test_file_str );
423+ TEST_CHECK_INT_EQUAL (sentry__path_write_buffer (test_file_path ,
424+ header_no_newline , sizeof (header_no_newline ) - 1 ),
425+ 0 );
426+ raw_envelope = sentry__envelope_from_path (test_file_path );
427+ TEST_CHECK (!!raw_envelope );
428+ event_id = sentry__envelope_get_event_id (raw_envelope );
429+ sentry_uuid_as_string (& event_id , event_id_str );
430+ TEST_CHECK_STRING_EQUAL (
431+ event_id_str , "c993afb6-b4ac-48a6-b61b-2558e601d65d" );
432+ sentry__path_remove (test_file_path );
433+ sentry__path_free (test_file_path );
434+ sentry_envelope_free (raw_envelope );
435+
436+ sentry_close ();
437+ }
438+
380439SENTRY_TEST (read_envelope_from_file )
381440{
382441 const char * test_file_str = SENTRY_TEST_PATH_PREFIX "sentry_test_envelope" ;
0 commit comments