@@ -1045,36 +1045,29 @@ func (s *WorkflowTestSuiteUnitTest) Test_WorkflowFullyQualifiedName() {
10451045
10461046func (s * WorkflowTestSuiteUnitTest ) Test_QueryWorkflow () {
10471047 queryType := "state"
1048- stateWaitTimer , stateWaitActivity , stateDone := "wait for timer " , "wait for activity" , "done"
1048+ stateWaitSignal , stateWaitActivity , stateDone := "wait for signal " , "wait for activity" , "done"
10491049 workflowFn := func (ctx Context ) error {
10501050 var state string
10511051 err := SetQueryHandler (ctx , queryType , func () (string , error ) {
10521052 return state , nil
10531053 })
10541054 if err != nil {
1055- state = err .Error ()
10561055 return err
10571056 }
10581057
1059- state = stateWaitTimer
1060- err = NewTimer (ctx , time .Hour ).Get (ctx , nil )
1061- if err != nil {
1062- state = err .Error ()
1063- return err
1064- }
1058+ state = stateWaitSignal
1059+ var signalData string
1060+ GetSignalChannel (ctx , "query-signal" ).Receive (ctx , & signalData )
10651061
10661062 state = stateWaitActivity
10671063 ctx = WithActivityOptions (ctx , s .activityOptions )
10681064 err = ExecuteActivity (ctx , testActivityHello , "mock_delay" ).Get (ctx , nil )
10691065 if err != nil {
1070- state = err .Error ()
10711066 return err
10721067 }
1073-
10741068 state = stateDone
10751069 return err
10761070 }
1077-
10781071 RegisterWorkflow (workflowFn )
10791072
10801073 env := s .NewTestWorkflowEnvironment ()
@@ -1086,9 +1079,10 @@ func (s *WorkflowTestSuiteUnitTest) Test_QueryWorkflow() {
10861079 s .NoError (err )
10871080 s .Equal (expected , state )
10881081 }
1089- env .SetOnTimerScheduledListener (func (timerID string , duration time.Duration ) {
1090- verifyStateWithQuery (stateWaitTimer )
1091- })
1082+ env .RegisterDelayedCallback (func () {
1083+ verifyStateWithQuery (stateWaitSignal )
1084+ env .SignalWorkflow ("query-signal" , "hello-query" )
1085+ }, time .Hour )
10921086 env .OnActivity (testActivityHello , mock .Anything , mock .Anything ).After (time .Hour ).Return ("hello_mock" , nil )
10931087 env .SetOnActivityStartedListener (func (activityInfo * ActivityInfo , ctx context.Context , args EncodedValues ) {
10941088 verifyStateWithQuery (stateWaitActivity )
@@ -1097,5 +1091,6 @@ func (s *WorkflowTestSuiteUnitTest) Test_QueryWorkflow() {
10971091
10981092 s .True (env .IsWorkflowCompleted ())
10991093 s .NoError (env .GetWorkflowError ())
1094+ env .AssertExpectations (s .T ())
11001095 verifyStateWithQuery (stateDone )
11011096}
0 commit comments