Skip to content

Commit

Permalink
Added "wait_for" to all the create, update, patch, delete endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Jul 9, 2020
1 parent 83c7d33 commit 62c874c
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('crete_list_item', () => {
body,
id: LIST_ITEM_ID,
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('index', expected);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const createListItem = async ({
body,
id,
index: listItemIndex,
refresh: 'wait_for',
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('crete_list_item_bulk', () => {
secondRecord,
],
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
});
});

Expand Down Expand Up @@ -70,6 +71,7 @@ describe('crete_list_item_bulk', () => {
},
],
index: '.items',
refresh: 'wait_for',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const createListItemsBulk = async ({
await callCluster('bulk', {
body,
index: listItemIndex,
refresh: 'wait_for',
});
} catch (error) {
// TODO: Log out the error with return values from the bulk insert into another index or saved object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('delete_list_item', () => {
const deleteQuery = {
id: LIST_ITEM_ID,
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('delete', deleteQuery);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const deleteListItem = async ({
await callCluster('delete', {
id,
index: listItemIndex,
refresh: 'wait_for',
});
}
return listItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('delete_list_item_by_value', () => {
},
},
index: '.items',
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('deleteByQuery', deleteByQuery);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const deleteListItemByValue = async ({
},
},
index: listItemIndex,
refresh: 'wait_for',
});
return listItems;
};
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const updateListItem = async ({
},
id: listItem.id,
index: listItemIndex,
refresh: 'wait_for',
});
return {
created_at: listItem.created_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('crete_list', () => {
body,
id: LIST_ID,
index: LIST_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('index', expected);
});
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lists/server/services/lists/create_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const createList = async ({
body,
id,
index: listIndex,
refresh: 'wait_for',
});
return {
id: response._id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('delete_list', () => {
const deleteByQuery = {
body: { query: { term: { list_id: LIST_ID } } },
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('deleteByQuery', deleteByQuery);
});
Expand All @@ -59,6 +60,7 @@ describe('delete_list', () => {
const deleteQuery = {
id: LIST_ID,
index: LIST_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toHaveBeenNthCalledWith(2, 'delete', deleteQuery);
});
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lists/server/services/lists/delete_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export const deleteList = async ({
},
},
index: listItemIndex,
refresh: 'wait_for',
});

await callCluster('delete', {
id,
index: listIndex,
refresh: 'wait_for',
});
return list;
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lists/server/services/lists/update_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const updateList = async ({
body: { doc },
id,
index: listIndex,
refresh: 'wait_for',
});
return {
created_at: list.created_at,
Expand Down

0 comments on commit 62c874c

Please sign in to comment.