-
Notifications
You must be signed in to change notification settings - Fork 198
/
workflow_test.go
40 lines (33 loc) · 1023 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
// @@@SNIPSTART samples-go-branch-workflow-definition-test
package branch
import (
"sort"
"testing"
"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_BranchWorkflow() {
env := s.NewTestWorkflowEnvironment()
env.RegisterActivity(SampleActivity)
env.OnActivity(SampleActivity, mock.Anything).Return("one", nil).Once()
env.OnActivity(SampleActivity, mock.Anything).Return("two", nil).Once()
env.OnActivity(SampleActivity, mock.Anything).Return("three", nil).Once()
env.ExecuteWorkflow(SampleBranchWorkflow, 3)
s.True(env.IsWorkflowCompleted())
s.NoError(env.GetWorkflowError())
var result []string
s.NoError(env.GetWorkflowResult(&result))
sort.Strings(result)
expected := []string{"one", "two", "three"}
sort.Strings(expected)
s.Equal(expected, result)
}
// @@@SNIPEND