Skip to content

Commit

Permalink
Fix UpsertSearchAttributes mocking (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
yux0 committed Oct 1, 2020
1 parent d0966cf commit 61f90c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/internal_workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1855,10 +1855,10 @@ func (env *testWorkflowEnvironmentImpl) UpsertSearchAttributes(attributes map[st
// mock found, check if return is error
args := []interface{}{attributes}
mockRet := env.mock.MethodCalled(mockMethod, args...)
if len(mockRet) != 1 {
if len(mockRet) > 1 {
panic(fmt.Sprintf("mock of UpsertSearchAttributes should return only one error"))
}
if mockRet[0] != nil {
if len(mockRet) == 1 && mockRet[0] != nil {
return mockRet[0].(error)
}
}
Expand Down
10 changes: 10 additions & 0 deletions internal/internal_workflow_testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,16 @@ func (s *WorkflowTestSuiteUnitTest) Test_MockUpsertSearchAttributes() {
s.Nil(env.GetWorkflowError())
env.AssertExpectations(s.T())

// mock no return
env = s.NewTestWorkflowEnvironment()
env.OnUpsertSearchAttributes(map[string]interface{}{}).Once()
env.OnUpsertSearchAttributes(map[string]interface{}{"CustomIntField": 1}).Once()

env.ExecuteWorkflow(workflowFn)
s.True(env.IsWorkflowCompleted())
s.Nil(env.GetWorkflowError())
env.AssertExpectations(s.T())

// mix no-mock and mock is not support
}

Expand Down

0 comments on commit 61f90c6

Please sign in to comment.