@@ -840,6 +840,94 @@ func TestMutableSideEffect(t *testing.T) {
840840 })
841841}
842842
843+ func TestEventHandler_handleMarkerRecorded (t * testing.T ) {
844+ for _ , tc := range []struct {
845+ marker * s.MarkerRecordedEventAttributes
846+ assertResult func (t * testing.T , result * workflowExecutionEventHandlerImpl )
847+ }{
848+ {
849+ marker : & s.MarkerRecordedEventAttributes {
850+ MarkerName : common .StringPtr (sideEffectMarkerName ),
851+ Details : getSerializedDetails (t , 1 , []byte ("test" )),
852+ },
853+ assertResult : func (t * testing.T , result * workflowExecutionEventHandlerImpl ) {
854+ require .Contains (t , result .sideEffectResult , int32 (1 ))
855+ assert .Equal (t , []byte ("test" ), result .sideEffectResult [1 ])
856+ },
857+ },
858+ {
859+ marker : & s.MarkerRecordedEventAttributes {
860+ MarkerName : common .StringPtr (versionMarkerName ),
861+ Details : getSerializedDetails (t , "test-version" , Version (1 )),
862+ },
863+ assertResult : func (t * testing.T , result * workflowExecutionEventHandlerImpl ) {
864+ require .Contains (t , result .changeVersions , "test-version" )
865+ assert .Equal (t , Version (1 ), result .changeVersions ["test-version" ])
866+ },
867+ },
868+ {
869+ marker : & s.MarkerRecordedEventAttributes {
870+ MarkerName : common .StringPtr (mutableSideEffectMarkerName ),
871+ Details : getSerializedDetails (t , "test-marker" , "test" ),
872+ },
873+ assertResult : func (t * testing.T , result * workflowExecutionEventHandlerImpl ) {
874+ require .Contains (t , result .mutableSideEffect , "test-marker" )
875+ assert .Equal (t , []byte ("test" ), result .mutableSideEffect ["test-marker" ])
876+ },
877+ },
878+ } {
879+ weh := testWorkflowExecutionEventHandler (t , newRegistry ())
880+ err := weh .handleMarkerRecorded (1 , tc .marker )
881+ assert .NoError (t , err )
882+ }
883+ }
884+
885+ func TestEventHandler_handleMarkerRecorded_failures (t * testing.T ) {
886+ for _ , tc := range []struct {
887+ name string
888+ marker * s.MarkerRecordedEventAttributes
889+ assertErrorStr string
890+ }{
891+ {
892+ name : "unknown marker" ,
893+ marker : & s.MarkerRecordedEventAttributes {
894+ MarkerName : common .StringPtr ("unknown" ),
895+ },
896+ assertErrorStr : "unknown marker name \" unknown\" for eventID \" 1\" " ,
897+ },
898+ {
899+ name : "side effect with invalid details" ,
900+ marker : & s.MarkerRecordedEventAttributes {
901+ MarkerName : common .StringPtr (sideEffectMarkerName ),
902+ Details : []byte ("invalid" ),
903+ },
904+ assertErrorStr : "extract side effect: unable to decode argument:" ,
905+ },
906+ {
907+ name : "version with invalid details" ,
908+ marker : & s.MarkerRecordedEventAttributes {
909+ MarkerName : common .StringPtr (versionMarkerName ),
910+ Details : []byte ("invalid" ),
911+ },
912+ assertErrorStr : "extract change id: unable to decode argument:" ,
913+ },
914+ {
915+ name : "mutable side effect with invalid details" ,
916+ marker : & s.MarkerRecordedEventAttributes {
917+ MarkerName : common .StringPtr (mutableSideEffectMarkerName ),
918+ Details : []byte ("invalid" ),
919+ },
920+ assertErrorStr : "extract fixed id: unable to decode argument:" ,
921+ },
922+ } {
923+ t .Run (tc .name , func (t * testing.T ) {
924+ weh := testWorkflowExecutionEventHandler (t , newRegistry ())
925+ err := weh .handleMarkerRecorded (1 , tc .marker )
926+ assert .ErrorContains (t , err , tc .assertErrorStr )
927+ })
928+ }
929+ }
930+
843931func testWorkflowExecutionEventHandler (t * testing.T , registry * registry ) * workflowExecutionEventHandlerImpl {
844932 return newWorkflowExecutionEventHandler (
845933 testWorkflowInfo ,
@@ -861,3 +949,10 @@ var testWorkflowInfo = &WorkflowInfo{
861949 Path : "" ,
862950 },
863951}
952+
953+ func getSerializedDetails [T , V any ](t * testing.T , id T , data V ) []byte {
954+ converter := defaultDataConverter {}
955+ res , err := converter .ToData (id , data )
956+ require .NoError (t , err )
957+ return res
958+ }
0 commit comments