Skip to content

Commit

Permalink
Added tests for DeleteTaskList (#6047)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobht authored May 24, 2024
1 parent af960df commit edc5880
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions common/persistence/nosql/nosql_task_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,27 @@ func TestUpdateTaskList_ConditionFailure(t *testing.T) {
assert.ErrorContains(t, err, "Failed to update task list. name: test-tasklist, type: 0, rangeID: 1, columns: (test-details)")
}

func TestDeleteTaskList(t *testing.T) {
store, db := setupNoSQLStoreMocks(t)
db.EXPECT().DeleteTaskList(gomock.Any(), getDecisionTaskListFilter(), int64(0)).Return(nil)

err := store.DeleteTaskList(context.Background(), getValidDeleteTaskListRequest())
assert.NoError(t, err)
}

func TestDeleteTaskList_ConditionFailure(t *testing.T) {
store, db := setupNoSQLStoreMocks(t)
db.EXPECT().DeleteTaskList(gomock.Any(), getDecisionTaskListFilter(), int64(0)).Return(
&nosqlplugin.TaskOperationConditionFailure{Details: "test-details"},
)

err := store.DeleteTaskList(context.Background(), getValidDeleteTaskListRequest())

var expectedErr *persistence.ConditionFailedError
assert.ErrorAs(t, err, &expectedErr)
assert.ErrorContains(t, err, "Failed to delete task list. name: test-tasklist, type: 0, rangeID: 0, columns: (test-details)")
}

func TestGetTasks(t *testing.T) {
store, db := setupNoSQLStoreMocks(t)
now := time.Unix(123, 456)
Expand Down Expand Up @@ -403,14 +424,6 @@ func getDecisionTaskListFilter() *nosqlplugin.TaskListFilter {
}
}

func getExpectedTaskListFilter() *nosqlplugin.TaskListFilter {
return &nosqlplugin.TaskListFilter{
DomainID: TestDomainID,
TaskListName: TestTaskListName,
TaskListType: int(types.TaskListTypeDecision),
}
}

func getExpectedTaskListRow() *nosqlplugin.TaskListRow {
return &nosqlplugin.TaskListRow{
DomainID: TestDomainID,
Expand Down Expand Up @@ -443,3 +456,13 @@ func getExpectedTaskListInfo() *persistence.TaskListInfo {
LastUpdated: time.Now(),
}
}

func getValidDeleteTaskListRequest() *persistence.DeleteTaskListRequest {
return &persistence.DeleteTaskListRequest{
DomainID: TestDomainID,
DomainName: TestDomainName,
TaskListName: TestTaskListName,
TaskListType: int(types.TaskListTypeDecision),
RangeID: 0,
}
}

0 comments on commit edc5880

Please sign in to comment.