Skip to content

Commit

Permalink
copyright & lint task_handler_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ketsiambaku committed Apr 30, 2024
1 parent 70c78f5 commit 79d97ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions service/history/decision/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,15 @@ func TestHandleDecisionTaskCompleted(t *testing.T) {
{
name: "failure to load workflow execution - shard closed",
domainID: constants.TestDomainID,
expectedErr: shard.ErrShardClosed,
expectedErr: errors.New("some random error"),
expectMockCalls: func(ctrl *gomock.Controller, decisionHandler *handlerImpl) {
deserializedTestToken := &common.TaskToken{
DomainID: constants.TestDomainID,
WorkflowID: constants.TestWorkflowID,
RunID: constants.TestRunID,
}
decisionHandler.tokenSerializer.(*common.MockTaskTokenSerializer).EXPECT().Deserialize(serializedTestToken).Return(deserializedTestToken, nil)
decisionHandler.shard.(*shard.MockContext).EXPECT().GetWorkflowExecution(context.Background(), gomock.Any()).Times(1).Return(nil, shard.ErrShardClosed)
decisionHandler.shard.(*shard.MockContext).EXPECT().GetWorkflowExecution(context.Background(), gomock.Any()).Times(1).Return(nil, errors.New("some random error"))
},
},
{
Expand Down
41 changes: 30 additions & 11 deletions service/history/decision/task_handler_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
// The MIT License (MIT)

// Copyright (c) 2017-2020 Uber Technologies Inc.

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package decision

import (
"context"
"errors"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/uber-go/tally"

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cache"
"github.com/uber/cadence/common/log/testlogger"
Expand All @@ -16,11 +41,10 @@ import (
"github.com/uber/cadence/service/history/config"
"github.com/uber/cadence/service/history/constants"
"github.com/uber/cadence/service/history/execution"
"testing"
)

const (
testTaskCompletedID = int64(1234)
testTaskCompletedID = int64(123)
)

func TestHandleDecisionRequestCancelExternalWorkflow(t *testing.T) {
Expand Down Expand Up @@ -81,7 +105,7 @@ func TestHandleDecisionRequestCancelExternalWorkflow(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
taskHandler := constructTestTaskHandler(t)
taskHandler := newTaskHandlerForTest(t)
taskHandler.mutableState.(*execution.MockMutableState).EXPECT().GetExecutionInfo().Times(1).Return(&persistence.WorkflowExecutionInfo{
DomainID: constants.TestDomainID,
WorkflowID: constants.TestWorkflowID,
Expand All @@ -98,7 +122,6 @@ func TestHandleDecisionRequestCancelExternalWorkflow(t *testing.T) {
}

func TestHandleDecisionRequestCancelActivity(t *testing.T) {

tests := []struct {
name string
expectMockCalls func(taskHandler *taskHandlerImpl)
Expand Down Expand Up @@ -183,7 +206,7 @@ func TestHandleDecisionRequestCancelActivity(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
taskHandler := constructTestTaskHandler(t)
taskHandler := newTaskHandlerForTest(t)
taskHandler.mutableState.(*execution.MockMutableState).EXPECT().AddRequestCancelExternalWorkflowExecutionInitiatedEvent(testTaskCompletedID, gomock.Any(), test.attributes).AnyTimes()
if test.expectMockCalls != nil {
test.expectMockCalls(taskHandler)
Expand All @@ -194,11 +217,7 @@ func TestHandleDecisionRequestCancelActivity(t *testing.T) {
}
}

func TestHandleDecisionStartChildWorkflow(t *testing.T) {

}

func constructTestTaskHandler(t *testing.T) *taskHandlerImpl {
func newTaskHandlerForTest(t *testing.T) *taskHandlerImpl {
ctrl := gomock.NewController(t)
testLogger := testlogger.New(t)
testConfig := config.NewForTest()
Expand All @@ -223,7 +242,7 @@ func constructTestTaskHandler(t *testing.T) *taskHandlerImpl {
testTaskCompletedID,
constants.TestLocalDomainEntry,
mockMutableState,
newAttrValidator(mockDomainCache, metrics.NewClient(tally.NoopScope, metrics.History), config.NewForTest(), testlogger.New(t)),
newAttrValidator(mockDomainCache, metrics.NewClient(tally.NoopScope, metrics.History), testConfig, testlogger.New(t)),
workflowSizeChecker,
common.NewMockTaskTokenSerializer(ctrl),
testLogger,
Expand Down

0 comments on commit 79d97ae

Please sign in to comment.