Skip to content

Commit

Permalink
Added tests for CompleteTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobht committed May 24, 2024
1 parent edc5880 commit dfe581c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions common/persistence/nosql/nosql_task_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,54 @@ func TestGetTasks_Empty(t *testing.T) {
assert.Empty(t, resp.Tasks)
}

func TestCompleteTask(t *testing.T) {
store, db := setupNoSQLStoreMocks(t)

// The main assertion is that the correct parameters are passed to the DB
db.EXPECT().RangeDeleteTasks(gomock.Any(), &nosqlplugin.TasksFilter{
TaskListFilter: *getDecisionTaskListFilter(),
MinTaskID: 11,
MaxTaskID: 12,
BatchSize: 1,
}).Return(1, nil)

err := store.CompleteTask(context.Background(), &persistence.CompleteTaskRequest{
TaskList: &persistence.TaskListInfo{
DomainID: TestDomainID,
Name: TestTaskListName,
TaskType: int(types.TaskListTypeDecision),
},
TaskID: 12,
DomainName: TestDomainName,
})

assert.NoError(t, err)
}

func TestCompleteTasksLessThan(t *testing.T) {
store, db := setupNoSQLStoreMocks(t)

// The main assertion is that the correct parameters are passed to the DB
db.EXPECT().RangeDeleteTasks(gomock.Any(), &nosqlplugin.TasksFilter{
TaskListFilter: *getDecisionTaskListFilter(),
MinTaskID: 0,
MaxTaskID: 12,
BatchSize: 100,
}).Return(13, nil)

resp, err := store.CompleteTasksLessThan(context.Background(), &persistence.CompleteTasksLessThanRequest{
DomainID: TestDomainID,
TaskListName: TestTaskListName,
TaskType: 0,
TaskID: 12,
Limit: 100,
DomainName: TestDomainName,
})

assert.NoError(t, err)
assert.Equal(t, 13, resp.TasksCompleted)
}

func getValidLeaseTaskListRequest() *persistence.LeaseTaskListRequest {
return &persistence.LeaseTaskListRequest{
DomainID: TestDomainID,
Expand Down

0 comments on commit dfe581c

Please sign in to comment.