-
Notifications
You must be signed in to change notification settings - Fork 202
/
parent_workflow_test.go
45 lines (36 loc) · 1.31 KB
/
parent_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
package child_workflow_test
import (
"github.com/stretchr/testify/mock"
"go.temporal.io/sdk/workflow"
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/sdk/testsuite"
"github.com/temporalio/samples-go/child-workflow"
)
func Test_Workflow_Integration(t *testing.T) {
testSuite := &testsuite.WorkflowTestSuite{}
env := testSuite.NewTestWorkflowEnvironment()
env.RegisterWorkflow(child_workflow.SampleChildWorkflow)
env.ExecuteWorkflow(child_workflow.SampleParentWorkflow)
require.True(t, env.IsWorkflowCompleted())
require.NoError(t, env.GetWorkflowError())
var result string
require.NoError(t, env.GetWorkflowResult(&result))
require.Equal(t, "Hello World!", result)
}
func Test_Workflow_Isolation(t *testing.T) {
testSuite := &testsuite.WorkflowTestSuite{}
env := testSuite.NewTestWorkflowEnvironment()
env.RegisterWorkflow(child_workflow.SampleChildWorkflow)
env.OnWorkflow("SampleChildWorkflow", mock.Anything, mock.Anything).Return(
func(ctx workflow.Context, name string) (string, error) {
return "Hi " + name + "!", nil
},
)
env.ExecuteWorkflow(child_workflow.SampleParentWorkflow)
require.True(t, env.IsWorkflowCompleted())
require.NoError(t, env.GetWorkflowError())
var result string
require.NoError(t, env.GetWorkflowResult(&result))
require.Equal(t, "Hi World!", result)
}