forked from temporalio/samples-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
await_signals_workflow_test.go
61 lines (51 loc) · 1.47 KB
/
await_signals_workflow_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package await_signals
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/testsuite"
)
type UnitTestSuite struct {
suite.Suite
testsuite.WorkflowTestSuite
}
func TestUnitTestSuite(t *testing.T) {
suite.Run(t, new(UnitTestSuite))
}
func (s *UnitTestSuite) Test_WorkflowTimeout() {
env := s.NewTestWorkflowEnvironment()
env.ExecuteWorkflow(AwaitSignalsWorkflow)
s.True(env.IsWorkflowCompleted())
// Workflow times out
s.Error(env.GetWorkflowError())
}
func (s *UnitTestSuite) Test_SignalsInOrder() {
env := s.NewTestWorkflowEnvironment()
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal1", nil)
}, time.Hour)
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal2", nil)
}, time.Hour+time.Second)
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal3", nil)
}, time.Hour+3*time.Second)
env.ExecuteWorkflow(AwaitSignalsWorkflow)
s.True(env.IsWorkflowCompleted())
s.NoError(env.GetWorkflowError())
}
func (s *UnitTestSuite) Test_SignalsInReverseOrder() {
env := s.NewTestWorkflowEnvironment()
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal3", nil)
}, time.Hour)
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal2", nil)
}, time.Hour+time.Second)
env.RegisterDelayedCallback(func() {
env.SignalWorkflow("Signal1", nil)
}, time.Hour+3*time.Second)
env.ExecuteWorkflow(AwaitSignalsWorkflow)
s.True(env.IsWorkflowCompleted())
s.NoError(env.GetWorkflowError())
}