@@ -980,8 +980,10 @@ func TestScheduledWorkflows(t *testing.T) {
980980}
981981
982982var (
983- sendWf = WithWorkflow (sendWorkflow )
984- receiveWf = WithWorkflow (receiveWorkflow )
983+ sendWf = WithWorkflow (sendWorkflow )
984+ receiveWf = WithWorkflow (receiveWorkflow )
985+ sendStructWf = WithWorkflow (sendStructWorkflow )
986+ receiveStructWf = WithWorkflow (receiveStructWorkflow )
985987)
986988
987989type sendWorkflowInput struct {
@@ -1023,6 +1025,20 @@ func receiveWorkflow(ctx context.Context, topic string) (string, error) {
10231025 return msg1 + "-" + msg2 + "-" + msg3 , nil
10241026}
10251027
1028+ func sendStructWorkflow (ctx context.Context , input sendWorkflowInput ) (string , error ) {
1029+ testStruct := sendRecvType {Value : "test-struct-value" }
1030+ err := Send (ctx , WorkflowSendInput {DestinationID : input .DestinationID , Topic : input .Topic , Message : testStruct })
1031+ return "" , err
1032+ }
1033+
1034+ func receiveStructWorkflow (ctx context.Context , topic string ) (sendRecvType , error ) {
1035+ return Recv [sendRecvType ](ctx , WorkflowRecvInput {Topic : topic , Timeout : 3 * time .Second })
1036+ }
1037+
1038+ type sendRecvType struct {
1039+ Value string
1040+ }
1041+
10261042func TestSendRecv (t * testing.T ) {
10271043 setupDBOS (t )
10281044
@@ -1102,6 +1118,39 @@ func TestSendRecv(t *testing.T) {
11021118 }
11031119 })
11041120
1121+ t .Run ("SendRecvCustomStruct" , func (t * testing.T ) {
1122+ // Start the receive workflow
1123+ receiveHandle , err := receiveStructWf (context .Background (), "struct-topic" )
1124+ if err != nil {
1125+ t .Fatalf ("failed to start receive workflow: %v" , err )
1126+ }
1127+
1128+ // Send the struct to the receive workflow
1129+ sendHandle , err := sendStructWf (context .Background (), sendWorkflowInput {
1130+ DestinationID : receiveHandle .GetWorkflowID (),
1131+ Topic : "struct-topic" ,
1132+ })
1133+ if err != nil {
1134+ t .Fatalf ("failed to send struct: %v" , err )
1135+ }
1136+
1137+ _ , err = sendHandle .GetResult (context .Background ())
1138+ if err != nil {
1139+ t .Fatalf ("failed to get result from send workflow: %v" , err )
1140+ }
1141+
1142+ // Get the result from receive workflow
1143+ result , err := receiveHandle .GetResult (context .Background ())
1144+ if err != nil {
1145+ t .Fatalf ("failed to get result from receive workflow: %v" , err )
1146+ }
1147+
1148+ // Verify the struct was received correctly
1149+ if result .Value != "test-struct-value" {
1150+ t .Fatalf ("expected received struct value to be 'test-struct-value', got '%s'" , result .Value )
1151+ }
1152+ })
1153+
11051154 t .Run ("SendToNonExistentUUID" , func (t * testing.T ) {
11061155 // Generate a non-existent UUID
11071156 destUUID := uuid .NewString ()
0 commit comments