@@ -399,6 +399,7 @@ func TestGetEventWithAllHeaderFields(t *testing.T) {
399399 DataVersion : dataType ,
400400 SpecVersion : cloudevent .SpecVersion ,
401401 Signature : "0x1234567890" ,
402+ RawEventID : "raw-event-id-123" ,
402403 Tags : []string {"tests.tag1" , "tests.tag2" },
403404 Extras : map [string ]any {
404405 "extraField" : "extra-value" ,
@@ -458,6 +459,7 @@ func TestGetEventWithAllHeaderFields(t *testing.T) {
458459 assert .Equal (t , fullHeaderEvent .DataVersion , retrievedEvent .DataVersion , "DataVersion mismatch" )
459460 assert .Equal (t , cloudevent .SpecVersion , retrievedEvent .SpecVersion , "SpecVersion mismatch" )
460461 assert .Equal (t , fullHeaderEvent .Signature , retrievedEvent .Signature , "Signature mismatch" )
462+ assert .Equal (t , fullHeaderEvent .RawEventID , retrievedEvent .RawEventID , "RawEventID mismatch" )
461463 assert .Equal (t , fullHeaderEvent .Tags , retrievedEvent .Tags , "Tags mismatch" )
462464
463465 // Verify extras
@@ -492,6 +494,37 @@ func TestGetEventWithAllHeaderFields(t *testing.T) {
492494 assert .Equal (t , "0x09876543210" , retrievedEvent .Signature , "Signature field not set correctly" )
493495 assert .Nil (t , retrievedEvent .Extras ["signature" ], "Signature should not be in extras" )
494496 })
497+
498+ t .Run ("retrieve event with raw event id that is originally in extras" , func (t * testing.T ) {
499+ fullHeaderEvent3 := fullHeaderEvent
500+ fullHeaderEvent3 .Subject = eventDID2 .String ()
501+ fullHeaderEvent3 .RawEventID = ""
502+ fullHeaderEvent3 .Extras = map [string ]any {
503+ "raweventid" : "raw-event-id-from-extras" ,
504+ }
505+ indexKey3 := insertTestData (t , ctx , conn , & fullHeaderEvent3 )
506+
507+ mockS3Client .EXPECT ().GetObject (gomock .Any (), gomock .Any (), gomock .Any ()).DoAndReturn (
508+ func (ctx context.Context , params * s3.GetObjectInput , optFns ... func (* s3.Options )) (* s3.GetObjectOutput , error ) {
509+ require .Equal (t , indexKey3 , * params .Key )
510+ return & s3.GetObjectOutput {
511+ Body : io .NopCloser (bytes .NewReader (eventDataEnvelope )),
512+ ContentLength : ref (int64 (len (eventDataEnvelope ))),
513+ }, nil
514+ },
515+ )
516+ opts := & grpc.SearchOptions {
517+ DataVersion : & wrapperspb.StringValue {Value : dataType },
518+ Subject : & wrapperspb.StringValue {Value : eventDID2 .String ()},
519+ }
520+
521+ retrievedEvent , err := indexService .GetLatestCloudEvent (ctx , "test-bucket" , opts )
522+ require .NoError (t , err )
523+
524+ assert .Equal (t , fullHeaderEvent3 .ID , retrievedEvent .ID , "ID mismatch" )
525+ assert .Equal (t , "raw-event-id-from-extras" , retrievedEvent .RawEventID , "RawEventID field not set correctly" )
526+ assert .Nil (t , retrievedEvent .Extras ["raweventid" ], "RawEventID should not be in extras" )
527+ })
495528}
496529
497530func ref [T any ](x T ) * T {
0 commit comments