@@ -580,7 +580,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ChildWorkflow_Listener() {
580580 s .NoError (env .GetWorkflowResult (& actualResult ))
581581 s .Equal ("hello_activity hello_world" , actualResult )
582582 s .Equal ("hello_world" , childWorkflowResult )
583- s .Equal (getFunctionName ( testWorkflowHello ) , childWorkflowName )
583+ s .Equal (" testWorkflowHello" , childWorkflowName )
584584}
585585
586586func (s * WorkflowTestSuiteUnitTest ) Test_ChildWorkflow_Clock () {
@@ -732,23 +732,23 @@ func (s *WorkflowTestSuiteUnitTest) Test_MockWorkflowWait() {
732732
733733 // no delay to the mock call, workflow should return no error
734734 env := s .NewTestWorkflowEnvironment ()
735- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).Return ("hello_mock_delayed" , nil ).Once ()
735+ env .OnWorkflow (testWorkflowHello , mock .Anything ).Return ("hello_mock_delayed" , nil ).Once ()
736736 env .ExecuteWorkflow (workflowFn )
737737 s .True (env .IsWorkflowCompleted ())
738738 s .NoError (env .GetWorkflowError ())
739739 env .AssertExpectations (s .T ())
740740
741741 // delay 10 minutes, which is shorter than the 1 hour timer, so workflow should return no error.
742742 env = s .NewTestWorkflowEnvironment ()
743- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).After (time .Minute * 10 ).Return ("hello_mock_delayed" , nil ).Once ()
743+ env .OnWorkflow (testWorkflowHello , mock .Anything ).After (time .Minute * 10 ).Return ("hello_mock_delayed" , nil ).Once ()
744744 env .ExecuteWorkflow (workflowFn )
745745 s .True (env .IsWorkflowCompleted ())
746746 s .NoError (env .GetWorkflowError ())
747747 env .AssertExpectations (s .T ())
748748
749749 // delay 2 hours, which is longer than the 1 hour timer, and workflow should return error.
750750 env = s .NewTestWorkflowEnvironment ()
751- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).After (time .Hour * 2 ).Return ("hello_mock_delayed" , nil ).Once ()
751+ env .OnWorkflow (testWorkflowHello , mock .Anything ).After (time .Hour * 2 ).Return ("hello_mock_delayed" , nil ).Once ()
752752 env .ExecuteWorkflow (workflowFn )
753753 s .True (env .IsWorkflowCompleted ())
754754 s .Error (env .GetWorkflowError ())
@@ -827,23 +827,23 @@ func (s *WorkflowTestSuiteUnitTest) Test_ChildWithChild() {
827827
828828 // no delay to the mock call, workflow should return no error
829829 env := s .NewTestWorkflowEnvironment ()
830- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).Return ("hello_mock_delayed" , nil ).Once ()
830+ env .OnWorkflow (testWorkflowHello , mock .Anything ).Return ("hello_mock_delayed" , nil ).Once ()
831831 env .ExecuteWorkflow (workflowFn )
832832 s .True (env .IsWorkflowCompleted ())
833833 s .NoError (env .GetWorkflowError ())
834834 env .AssertExpectations (s .T ())
835835
836836 // delay 10 minutes, which is shorter than the 1 hour timer, so workflow should return no error.
837837 env = s .NewTestWorkflowEnvironment ()
838- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).After (time .Minute * 10 ).Return ("hello_mock_delayed" , nil ).Once ()
838+ env .OnWorkflow (testWorkflowHello , mock .Anything ).After (time .Minute * 10 ).Return ("hello_mock_delayed" , nil ).Once ()
839839 env .ExecuteWorkflow (workflowFn )
840840 s .True (env .IsWorkflowCompleted ())
841841 s .NoError (env .GetWorkflowError ())
842842 env .AssertExpectations (s .T ())
843843
844844 // delay 2 hours, which is longer than the 1 hour timer, and workflow should return error.
845845 env = s .NewTestWorkflowEnvironment ()
846- env .OnWorkflow (testWorkflowHello , mock .Anything , mock . Anything ).After (time .Hour * 2 ).Return ("hello_mock_delayed" , nil ).Once ()
846+ env .OnWorkflow (testWorkflowHello , mock .Anything ).After (time .Hour * 2 ).Return ("hello_mock_delayed" , nil ).Once ()
847847 env .ExecuteWorkflow (workflowFn )
848848 s .True (env .IsWorkflowCompleted ())
849849 s .Error (env .GetWorkflowError ())
@@ -931,3 +931,66 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityWithThriftTypes() {
931931 }
932932 s .EqualValues (expectedValues , actualValues )
933933}
934+
935+ func (s * WorkflowTestSuiteUnitTest ) Test_ActivityFriendlyName () {
936+ activityFn := func (msg string ) (string , error ) {
937+ return "hello_" + msg , nil
938+ }
939+
940+ workflowFn := func (ctx Context ) error {
941+ ctx = WithActivityOptions (ctx , s .activityOptions )
942+ var result string
943+ err := ExecuteActivity (ctx , activityFn , "friendly_name" ).Get (ctx , & result )
944+ if err != nil {
945+ return err
946+ }
947+ err = ExecuteActivity (ctx , "foo" , "friendly_name" ).Get (ctx , & result )
948+ return err
949+ }
950+
951+ RegisterActivityWithOptions (activityFn , RegisterActivityOptions {Name : "foo" })
952+ RegisterWorkflow (workflowFn )
953+ env := s .NewTestWorkflowEnvironment ()
954+ var called []string
955+ env .SetOnActivityStartedListener (func (activityInfo * ActivityInfo , ctx context.Context , args EncodedValues ) {
956+ called = append (called , activityInfo .ActivityType .Name )
957+ })
958+
959+ env .ExecuteWorkflow (workflowFn )
960+
961+ s .True (env .IsWorkflowCompleted ())
962+ s .NoError (env .GetWorkflowError ())
963+ s .Equal (2 , len (called ))
964+ s .Equal ("foo" , called [0 ])
965+ s .Equal ("foo" , called [1 ])
966+ }
967+
968+ func (s * WorkflowTestSuiteUnitTest ) Test_WorkflowFriendlyName () {
969+
970+ workflowFn := func (ctx Context ) error {
971+ cwo := ChildWorkflowOptions {ExecutionStartToCloseTimeout : time .Hour /* this is currently ignored by test suite */ }
972+ ctx = WithChildWorkflowOptions (ctx , cwo )
973+ var result string
974+ err := ExecuteChildWorkflow (ctx , testWorkflowHello ).Get (ctx , & result )
975+ if err != nil {
976+ return err
977+ }
978+ err = ExecuteChildWorkflow (ctx , "testWorkflowHello" ).Get (ctx , & result )
979+ return err
980+ }
981+
982+ RegisterWorkflow (workflowFn )
983+ env := s .NewTestWorkflowEnvironment ()
984+ var called []string
985+ env .SetOnChildWorkflowStartedListener (func (workflowInfo * WorkflowInfo , ctx Context , args EncodedValues ) {
986+ called = append (called , workflowInfo .WorkflowType .Name )
987+ })
988+
989+ env .ExecuteWorkflow (workflowFn )
990+
991+ s .True (env .IsWorkflowCompleted ())
992+ s .NoError (env .GetWorkflowError ())
993+ s .Equal (2 , len (called ))
994+ s .Equal ("testWorkflowHello" , called [0 ])
995+ s .Equal ("testWorkflowHello" , called [1 ])
996+ }
0 commit comments