-
Notifications
You must be signed in to change notification settings - Fork 203
/
Copy pathworkflow_test.go
41 lines (31 loc) · 946 Bytes
/
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
package schedule
import (
"testing"
"time"
"github.com/stretchr/testify/mock"
"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_ScheduleWorkflow() {
env := s.NewTestWorkflowEnvironment()
env.RegisterWorkflow(SampleScheduleWorkflow)
env.RegisterActivity(DoSomething)
//lint:ignore SA1019 sample will be updated in the near future.
err := env.SetSearchAttributesOnStart(map[string]interface{}{
"TemporalScheduledById": "schedule_test_ID",
"TemporalScheduledStartTime": time.Now(),
})
s.NoError(err)
env.OnActivity(DoSomething, mock.Anything, mock.Anything, mock.Anything).Return(nil).Times(3)
env.ExecuteWorkflow(SampleScheduleWorkflow)
s.True(env.IsWorkflowCompleted())
err = env.GetWorkflowError()
s.NoError(err)
}