Skip to content

Commit

Permalink
respond to comment
Browse files Browse the repository at this point in the history
  • Loading branch information
timl3136 committed Jun 6, 2024
1 parent 7e115f0 commit d85f496
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions service/frontend/api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2328,28 +2328,32 @@ func (s *workflowHandlerSuite) TestRespondDecisionTaskCompleted() {
wh.tokenSerializer = s.mockTokenSerializer

testInput := map[string]struct {
input *types.RespondDecisionTaskCompletedRequest
mockFn func()
expectError bool
input *types.RespondDecisionTaskCompletedRequest
mockFn func()
expectError bool
expectErrorType error
}{
"shutting down": {
input: validRequest,
mockFn: func() {
wh.shuttingDown = int32(1)
},
expectError: true,
expectError: true,
expectErrorType: validate.ErrShuttingDown,
},
"nil request": {
input: nil,
mockFn: func() {},
expectError: true,
input: nil,
mockFn: func() {},
expectError: true,
expectErrorType: validate.ErrRequestNotSet,
},
"nil task token": {
input: &types.RespondDecisionTaskCompletedRequest{
TaskToken: nil,
},
mockFn: func() {},
expectError: true,
mockFn: func() {},
expectError: true,
expectErrorType: validate.ErrTaskTokenNotSet,
},
"deserialization failure": {
input: validRequest,
Expand All @@ -2363,7 +2367,8 @@ func (s *workflowHandlerSuite) TestRespondDecisionTaskCompleted() {
mockFn: func() {
s.mockTokenSerializer.EXPECT().Deserialize(gomock.Any()).Return(&common.TaskToken{DomainID: ""}, nil)
},
expectError: true,
expectError: true,
expectErrorType: validate.ErrDomainNotSet,
},
"cannot get domain name": {
input: validRequest,
Expand All @@ -2381,7 +2386,8 @@ func (s *workflowHandlerSuite) TestRespondDecisionTaskCompleted() {
wh.config.MaxIDLengthWarnLimit = dc.GetIntPropertyFn(1)
wh.config.IdentityMaxLength = dc.GetIntPropertyFilteredByDomain(1)
},
expectError: true,
expectError: true,
expectErrorType: validate.ErrIdentityTooLong,
},
"exceeds decision size limit": {
input: validRequest,
Expand Down Expand Up @@ -2438,6 +2444,9 @@ func (s *workflowHandlerSuite) TestRespondDecisionTaskCompleted() {
_, err := wh.RespondDecisionTaskCompleted(context.Background(), input.input)
if input.expectError {
s.Error(err)
if input.expectErrorType != nil {
s.ErrorIs(err, input.expectErrorType)
}
} else {
s.NoError(err)
}
Expand Down

0 comments on commit d85f496

Please sign in to comment.