Skip to content

Commit

Permalink
Tests for UpdateWorkflowEecution in nosql store-Part1 (cadence-workfl…
Browse files Browse the repository at this point in the history
  • Loading branch information
agautam478 authored and ketsiambaku committed Mar 6, 2024
1 parent 93fb79c commit 34f03c6
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions common/persistence/nosql/nosql_execution_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,35 @@ func TestNosqlExecutionStore(t *testing.T) {
},
expectedError: &types.EntityNotExistsError{},
},
{
name: "UpdateWorkflowExecution success",
setupMock: func(ctrl *gomock.Controller) *nosqlExecutionStore {
mockDB := nosqlplugin.NewMockDB(ctrl)
mockDB.EXPECT().
UpdateWorkflowExecutionWithTasks(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Nil(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(nil).Times(1)
return newTestNosqlExecutionStore(mockDB, log.NewNoop())
},
testFunc: func(store *nosqlExecutionStore) error {
err := store.UpdateWorkflowExecution(ctx, newUpdateWorkflowExecutionRequest())
return err
},
expectedError: nil,
},
{
name: "UpdateWorkflowExecution failure - invalid update mode",
setupMock: func(ctrl *gomock.Controller) *nosqlExecutionStore {
mockDB := nosqlplugin.NewMockDB(ctrl)
// No operation expected on the DB due to invalid mode
return newTestNosqlExecutionStore(mockDB, log.NewNoop())
},
testFunc: func(store *nosqlExecutionStore) error {
request := newUpdateWorkflowExecutionRequest()
request.Mode = persistence.UpdateWorkflowMode(-1) // Invalid mode
return store.UpdateWorkflowExecution(ctx, request)
},
expectedError: &types.InternalServiceError{},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -207,6 +236,21 @@ func newGetWorkflowExecutionRequest() *persistence.InternalGetWorkflowExecutionR
}
}

func newUpdateWorkflowExecutionRequest() *persistence.InternalUpdateWorkflowExecutionRequest {
return &persistence.InternalUpdateWorkflowExecutionRequest{
RangeID: 123,
UpdateWorkflowMutation: persistence.InternalWorkflowMutation{
ExecutionInfo: &persistence.InternalWorkflowExecutionInfo{
DomainID: constants.TestDomainID,
WorkflowID: constants.TestWorkflowID,
RunID: constants.TestRunID,
State: persistence.WorkflowStateCreated,
CloseStatus: persistence.WorkflowCloseStatusNone,
},
},
}
}

func getNewWorkflowSnapshot() persistence.InternalWorkflowSnapshot {
return persistence.InternalWorkflowSnapshot{
VersionHistories: &persistence.DataBlob{},
Expand Down

0 comments on commit 34f03c6

Please sign in to comment.