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 3175cfc commit 52facdd
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 @@ -2494,28 +2494,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 @@ -2529,7 +2533,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 @@ -2547,7 +2552,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 @@ -2604,6 +2610,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 52facdd

Please sign in to comment.