Skip to content

Commit

Permalink
+tests for Describe/RefreshTaskList, DescribeWorkflowExecution
Browse files Browse the repository at this point in the history
More tests to increase coverage of internal_workflow_client.go to 90%
  • Loading branch information
dkrotx committed Jun 23, 2024
1 parent 9a29436 commit 50e4093
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions internal/internal_workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,76 @@ func (s *workflowClientTestSuite) TestTerminateWorkflow() {
s.NoError(err)
}

func (s *workflowClientTestSuite) TestDescribeTaskList() {
testcases := []struct {
name string
rpcError error
response *shared.DescribeTaskListResponse
}{
{
name: "success",
rpcError: nil,
response: &shared.DescribeTaskListResponse{},
},
{
name: "failure",
rpcError: &shared.AccessDeniedError{},
response: nil,
},
}

for _, tt := range testcases {
s.Run(tt.name, func() {
expectedRequest := &shared.DescribeTaskListRequest{
Domain: common.StringPtr(domain),
TaskList: &shared.TaskList{Name: common.StringPtr(tasklist)},
TaskListType: shared.TaskListTypeActivity.Ptr(),
}
s.service.EXPECT().
DescribeTaskList(gomock.Any(), expectedRequest, gomock.Any()).
Return(tt.response, tt.rpcError)

r, err := s.client.DescribeTaskList(context.Background(), tasklist, shared.TaskListTypeActivity)
s.Equal(tt.rpcError, err, "error should be returned as-is")
s.Equal(tt.response, r)
})
}
}

func (s *workflowClientTestSuite) TestRefreshWorkflowTasks() {
testcases := []struct {
name string
rpcError error
}{
{
name: "success",
rpcError: nil,
},
{
name: "failure",
rpcError: &shared.AccessDeniedError{},
},
}

for _, tt := range testcases {
s.Run(tt.name, func() {
expectedRequest := &shared.RefreshWorkflowTasksRequest{
Domain: common.StringPtr(domain),
Execution: &shared.WorkflowExecution{
WorkflowId: common.StringPtr(workflowID),
RunId: common.StringPtr(runID),
},
}
s.service.EXPECT().
RefreshWorkflowTasks(gomock.Any(), expectedRequest, gomock.Any()).
Return(tt.rpcError)

err := s.client.RefreshWorkflowTasks(context.Background(), workflowID, runID)
s.Equal(tt.rpcError, err, "error should be returned as-is")
})
}
}

func (s *workflowClientTestSuite) TestListOpenWorkflow() {
testcases := []struct {
name string
Expand Down Expand Up @@ -1913,6 +1983,44 @@ func (s *workflowClientTestSuite) TestResetWorkflow() {
}
}

func (s *workflowClientTestSuite) TestDescribeWorkflowExecution() {
testcases := []struct {
name string
rpcError error
response *shared.DescribeWorkflowExecutionResponse
}{
{
name: "success",
rpcError: nil,
response: &shared.DescribeWorkflowExecutionResponse{},
},
{
name: "failure",
rpcError: &shared.AccessDeniedError{},
response: nil,
},
}

for _, tt := range testcases {
s.Run(tt.name, func() {
expectedRequest := &shared.DescribeWorkflowExecutionRequest{
Domain: common.StringPtr(domain),
Execution: &shared.WorkflowExecution{
WorkflowId: common.StringPtr(workflowID),
RunId: common.StringPtr(runID),
},
}
s.service.EXPECT().
DescribeWorkflowExecution(gomock.Any(), expectedRequest, gomock.Any()).
Return(tt.response, tt.rpcError)

r, err := s.client.DescribeWorkflowExecution(context.Background(), workflowID, runID)
s.Equal(tt.rpcError, err, "error should be returned as-is")
s.Equal(tt.response, r)
})
}
}

func (s *workflowClientTestSuite) TestQueryWorkflowWithOptions() {
testcases := []struct {
name string
Expand Down

0 comments on commit 50e4093

Please sign in to comment.