Skip to content

Commit

Permalink
One more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
agautam478 committed Jun 4, 2024
1 parent de89105 commit d03301c
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions service/history/engine/engineimpl/start_workflow_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestStartWorkflowExecution(t *testing.T) {
Identity: "workflow-starter",
RequestID: "request-id-for-start",
WorkflowType: &types.WorkflowType{Name: "workflow-type"},
WorkflowIDReusePolicy: (*types.WorkflowIDReusePolicy)(common.Int32Ptr(1)),
WorkflowIDReusePolicy: types.WorkflowIDReusePolicyAllowDuplicate.Ptr(),
},
},
setupMocks: func(t *testing.T, eft *testdata.EngineForTest) {
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestStartWorkflowExecution(t *testing.T) {
Identity: "workflow-starter",
RequestID: "request-id-for-start",
WorkflowType: &types.WorkflowType{Name: "workflow-type"},
WorkflowIDReusePolicy: (*types.WorkflowIDReusePolicy)(common.Int32Ptr(3)),
WorkflowIDReusePolicy: types.WorkflowIDReusePolicyTerminateIfRunning.Ptr(),
},
},
setupMocks: func(t *testing.T, eft *testdata.EngineForTest) {
Expand All @@ -197,6 +197,39 @@ func TestStartWorkflowExecution(t *testing.T) {
},
wantErr: false,
},
{
name: "workflow ID reuse policy - reject duplicate",
request: &types.HistoryStartWorkflowExecutionRequest{
DomainUUID: constants.TestDomainID,
StartRequest: &types.StartWorkflowExecutionRequest{
Domain: constants.TestDomainName,
WorkflowID: "workflow-id",
WorkflowType: &types.WorkflowType{Name: "workflow-type"},
TaskList: &types.TaskList{Name: "default-task-list"},
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(3600), // 1 hour
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(10), // 10 seconds
Identity: "workflow-starter",
RequestID: "request-id-for-start",
WorkflowIDReusePolicy: types.WorkflowIDReusePolicyRejectDuplicate.Ptr(),
},
},
setupMocks: func(t *testing.T, eft *testdata.EngineForTest) {
domainEntry := &cache.DomainCacheEntry{}
eft.ShardCtx.Resource.DomainCache.EXPECT().GetDomainByID(constants.TestDomainID).Return(domainEntry, nil).AnyTimes()

eft.ShardCtx.Resource.ExecutionMgr.On("CreateWorkflowExecution", mock.Anything, mock.Anything).Return(nil, &persistence.WorkflowExecutionAlreadyStartedError{
StartRequestID: "existing-request-id",
RunID: "existing-run-id",
}).Once()
eft.ShardCtx.Resource.ShardMgr.
On("UpdateShard", mock.Anything, mock.Anything).
Return(nil)
historyV2Mgr := eft.ShardCtx.Resource.HistoryMgr
historyV2Mgr.On("AppendHistoryNodes", mock.Anything, mock.AnythingOfType("*persistence.AppendHistoryNodesRequest")).
Return(&persistence.AppendHistoryNodesResponse{}, nil).Once()
},
wantErr: true,
},
}

for _, tc := range tests {
Expand Down

0 comments on commit d03301c

Please sign in to comment.