Skip to content

Commit

Permalink
Updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Aug 26, 2024
1 parent 76a4d9c commit 8212d4b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions x-pack/plugins/task_manager/server/task_pool/task_pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('TaskPool', () => {
expect(shouldNotRun).not.toHaveBeenCalled();
});

test('should log when marking a Task as running fails', async () => {
test('should log and throw an error when marking a Task as running fails', async () => {
const pool = new TaskPool({
capacity$: of(3),
definitions,
Expand All @@ -180,15 +180,15 @@ describe('TaskPool', () => {
throw new Error(`Mark Task as running has failed miserably`);
});

const result = await pool.run([mockTask(), taskFailedToMarkAsRunning, mockTask()]);
await expect(
pool.run([mockTask(), taskFailedToMarkAsRunning, mockTask()])
).rejects.toThrowError('Mark Task as running has failed miserably');

expect((logger as jest.Mocked<Logger>).error.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"Failed to mark Task TaskType \\"shooooo\\" as running: Mark Task as running has failed miserably",
]
`);

expect(result).toEqual(TaskPoolRunResult.RunningAllClaimedTasks);
});

test('should log when running a Task fails', async () => {
Expand Down Expand Up @@ -549,7 +549,7 @@ describe('TaskPool', () => {
expect(shouldNotRun).not.toHaveBeenCalled();
});

test('should log when marking a Task as running fails', async () => {
test('should log and throw an error when marking a Task as running fails', async () => {
const pool = new TaskPool({
capacity$: of(6),
definitions,
Expand All @@ -562,15 +562,15 @@ describe('TaskPool', () => {
throw new Error(`Mark Task as running has failed miserably`);
});

const result = await pool.run([mockTask(), taskFailedToMarkAsRunning, mockTask()]);
await expect(
pool.run([mockTask(), taskFailedToMarkAsRunning, mockTask()])
).rejects.toThrowError('Mark Task as running has failed miserably');

expect((logger as jest.Mocked<Logger>).error.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"Failed to mark Task TaskType \\"shooooo\\" as running: Mark Task as running has failed miserably",
]
`);

expect(result).toEqual(TaskPoolRunResult.RunningAllClaimedTasks);
Array [
"Failed to mark Task TaskType \\"shooooo\\" as running: Mark Task as running has failed miserably",
]
`);
});

test('should log when running a Task fails', async () => {
Expand Down

0 comments on commit 8212d4b

Please sign in to comment.