forked from temporalio/samples-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memo_workflow_test.go
32 lines (25 loc) · 897 Bytes
/
memo_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
package memo
import (
"testing"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
workflowpb "go.temporal.io/api/workflow/v1"
"go.temporal.io/sdk/testsuite"
)
func Test_Workflow(t *testing.T) {
testSuite := &testsuite.WorkflowTestSuite{}
env := testSuite.NewTestWorkflowEnvironment()
env.RegisterActivity(DescribeWorkflow)
// mock search attributes on start
_ = env.SetMemoOnStart(map[string]interface{}{"description": "Test memo workflow"})
// mock upsert operations
memo := map[string]interface{}{
"description": "Test upsert memo workflow",
}
env.OnUpsertMemo(memo).Return(nil).Once()
// mock activity
env.OnActivity(DescribeWorkflow, mock.Anything, mock.Anything).Return(&workflowpb.WorkflowExecutionInfo{}, nil).Once()
env.ExecuteWorkflow(MemoWorkflow)
require.True(t, env.IsWorkflowCompleted())
require.NoError(t, env.GetWorkflowError())
}