@@ -394,13 +394,21 @@ type TestData struct {
394394 Active bool
395395}
396396
397+ // NestedTestData is a nested struct type for testing slices and maps of structs
398+ type NestedTestData struct {
399+ Key string
400+ Count int
401+ }
402+
397403type TestWorkflowData struct {
398- ID string
399- Message string
400- Value int
401- Active bool
402- Data TestData
403- Metadata map [string ]string
404+ ID string
405+ Message string
406+ Value int
407+ Active bool
408+ Data TestData
409+ Metadata map [string ]string
410+ NestedSlice []NestedTestData
411+ NestedMap map [NestedTestData ]MyInt
404412}
405413
406414// Test workflows and steps
@@ -593,6 +601,7 @@ func init() {
593601
594602 // Register test data types (concrete structs)
595603 safeGobRegister (TestData {})
604+ safeGobRegister (NestedTestData {})
596605 safeGobRegister (TestWorkflowData {})
597606
598607 // Register custom type aliases (must register with concrete value)
@@ -609,20 +618,23 @@ func init() {
609618 safeGobRegister ([]int (nil ))
610619 safeGobRegister ([]string (nil ))
611620 safeGobRegister ([]bool (nil ))
621+ safeGobRegister ([]NestedTestData (nil ))
612622
613623 // Register maps with custom types
614624 safeGobRegister (map [string ]MyInt (nil ))
615625 safeGobRegister (map [string ]string (nil ))
616626 safeGobRegister (map [string ]int (nil ))
617627 safeGobRegister (map [string ]bool (nil ))
618628 safeGobRegister (map [string ]any (nil ))
629+ safeGobRegister (map [NestedTestData ]MyInt (nil ))
619630
620631 // Register pointer types
621632 safeGobRegister ((* int )(nil ))
622633 safeGobRegister ((* string )(nil ))
623634 safeGobRegister ((* bool )(nil ))
624635 safeGobRegister ((* TestWorkflowData )(nil ))
625636 safeGobRegister ((* TestData )(nil ))
637+ safeGobRegister ((* NestedTestData )(nil ))
626638 safeGobRegister ((* MyInt )(nil ))
627639 safeGobRegister ((* MyString )(nil ))
628640
@@ -688,6 +700,14 @@ func TestSerializer(t *testing.T) {
688700 Active : true ,
689701 Data : TestData {Message : "embedded" , Value : 123 , Active : false },
690702 Metadata : map [string ]string {"key" : "value" },
703+ NestedSlice : []NestedTestData {
704+ {Key : "nested1" , Count : 10 },
705+ {Key : "nested2" , Count : 20 },
706+ },
707+ NestedMap : map [NestedTestData ]MyInt {
708+ {Key : "map-key1" , Count : 1 }: MyInt (100 ),
709+ {Key : "map-key2" , Count : 2 }: MyInt (200 ),
710+ },
691711 }
692712
693713 handle , err := RunWorkflow (executor , serializerWorkflow , input )
@@ -713,6 +733,12 @@ func TestSerializer(t *testing.T) {
713733 Active : true ,
714734 Data : TestData {Message : "error data" , Value : 456 , Active : false },
715735 Metadata : map [string ]string {"type" : "error" },
736+ NestedSlice : []NestedTestData {
737+ {Key : "error-nested" , Count : 99 },
738+ },
739+ NestedMap : map [NestedTestData ]MyInt {
740+ {Key : "error-key" , Count : 999 }: MyInt (999 ),
741+ },
716742 }
717743
718744 handle , err := RunWorkflow (executor , serializerErrorWorkflow , input )
@@ -746,6 +772,12 @@ func TestSerializer(t *testing.T) {
746772 Active : true ,
747773 Data : TestData {Message : "nested" , Value : 200 , Active : true },
748774 Metadata : map [string ]string {"comm" : "sendrecv" },
775+ NestedSlice : []NestedTestData {
776+ {Key : "sendrecv-nested" , Count : 50 },
777+ },
778+ NestedMap : map [NestedTestData ]MyInt {
779+ {Key : "sendrecv-key" , Count : 5 }: MyInt (500 ),
780+ },
749781 }
750782
751783 testSendRecv (t , executor , serializerSenderWorkflow , serializerReceiverWorkflow , input , "sender-wf" )
@@ -760,6 +792,14 @@ func TestSerializer(t *testing.T) {
760792 Active : false ,
761793 Data : TestData {Message : "event nested" , Value : 333 , Active : true },
762794 Metadata : map [string ]string {"type" : "event" },
795+ NestedSlice : []NestedTestData {
796+ {Key : "event-nested1" , Count : 30 },
797+ {Key : "event-nested2" , Count : 40 },
798+ },
799+ NestedMap : map [NestedTestData ]MyInt {
800+ {Key : "event-key1" , Count : 3 }: MyInt (300 ),
801+ {Key : "event-key2" , Count : 4 }: MyInt (400 ),
802+ },
763803 }
764804
765805 testSetGetEvent (t , executor , serializerSetEventWorkflow , serializerGetEventWorkflow , input , "setevent-wf" , "getevent-wf" )
@@ -809,6 +849,12 @@ func TestSerializer(t *testing.T) {
809849 Active : true ,
810850 Data : TestData {Message : "recovery nested" , Value : 456 , Active : false },
811851 Metadata : map [string ]string {"type" : "recovery" },
852+ NestedSlice : []NestedTestData {
853+ {Key : "recovery-nested" , Count : 111 },
854+ },
855+ NestedMap : map [NestedTestData ]MyInt {
856+ {Key : "recovery-key" , Count : 11 }: MyInt (1111 ),
857+ },
812858 }
813859
814860 testWorkflowRecovery (t , executor , serializerRecoveryWorkflow , serializerRecoveryStartEvent , serializerRecoveryEvent , input , "serializer-recovery-wf" )
@@ -823,6 +869,12 @@ func TestSerializer(t *testing.T) {
823869 Active : false ,
824870 Data : TestData {Message : "queued nested" , Value : 789 , Active : true },
825871 Metadata : map [string ]string {"type" : "queued" },
872+ NestedSlice : []NestedTestData {
873+ {Key : "queued-nested" , Count : 222 },
874+ },
875+ NestedMap : map [NestedTestData ]MyInt {
876+ {Key : "queued-key" , Count : 22 }: MyInt (2222 ),
877+ },
826878 }
827879
828880 // Start workflow with queue option
0 commit comments