From e339604d5a215ff8b172b7370a7851087a10c260 Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Tue, 9 Aug 2022 17:59:51 +0300 Subject: [PATCH 1/7] feat: added task status api --- openapi3.yaml | 75 +++++++++++++++++++ src/clients/jobManagerWrapper.ts | 6 ++ src/common/interfaces.ts | 3 +- src/containerConfig.ts | 2 + .../controllers/tasksController.ts | 23 ++++++ src/createPackage/models/tasksManager.ts | 36 +++++++++ src/createPackage/routes/tasksRouter.ts | 17 +++++ src/serverBuilder.ts | 5 +- 8 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/createPackage/controllers/tasksController.ts create mode 100644 src/createPackage/models/tasksManager.ts create mode 100644 src/createPackage/routes/tasksRouter.ts diff --git a/openapi3.yaml b/openapi3.yaml index 7911ce2..3d0f3f1 100644 --- a/openapi3.yaml +++ b/openapi3.yaml @@ -44,6 +44,46 @@ paths: application/json: schema: $ref: '#/components/schemas/internalError' + /taskStatus/{jobId}: + get: + tags: + - tasks + summary: Get task status by job id + operationId: getTaskStatusByJobId + parameters: + - name: jobId + in: path + required: true + schema: + type: string + format: uuid + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/getTaskStatusResponse' + discriminator: + propertyName: response + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/error' + '404': + description: Could not find task with matched jobId + content: + application/json: + schema: + $ref: '#/components/schemas/error' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/internalError' components: requestBodies: ExportGetmapBody: @@ -53,6 +93,21 @@ components: application/json: schema: $ref: '#/components/schemas/exportGetMap' + getTasksByJobId: + description: get tasks by job id + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/exportGetMap' + parameters: + jobId: + in: path + name: jobId + description: ID of Job + required: true + schema: + $ref: '#/components/schemas/jobId' schemas: CommonResponse: type: object @@ -202,3 +257,23 @@ components: description: >- Bounding box corners (lower left, upper right)=[minx,miny,maxx,maxy] in crs units as array + jobId: + type: string + format: uuid + getTaskStatusResponse: + type: object + properties: + percentage: + type: number + minimum: 0 + maximum: 100 + description: percentage of task by job id + status: + type: string + enum: + - Completed + - In-Progress + - Pending + - Failed + - Expired + - Aborted diff --git a/src/clients/jobManagerWrapper.ts b/src/clients/jobManagerWrapper.ts index 6099565..249b6fd 100644 --- a/src/clients/jobManagerWrapper.ts +++ b/src/clients/jobManagerWrapper.ts @@ -14,6 +14,7 @@ import { IWorkerInput, JobDuplicationParams, JobResponse, + TaskResponse, } from '../common/interfaces'; @injectable() @@ -135,6 +136,11 @@ export class JobManagerWrapper extends JobManagerClient { return undefined; } + public async getTasksByJobId(jobId: string): Promise { + const tasks = await this.get(`/jobs/${jobId}/tasks`); + return tasks; + } + private async getJobs(queryParams: IFindJob): Promise { this.logger.info(`Getting jobs that match these parameters: ${JSON.stringify(queryParams)}`); const jobs = await this.get('/jobs', queryParams as unknown as Record); diff --git a/src/common/interfaces.ts b/src/common/interfaces.ts index 068defa..362be43 100644 --- a/src/common/interfaces.ts +++ b/src/common/interfaces.ts @@ -1,4 +1,4 @@ -import { ICreateJobBody, IJobResponse, OperationStatus } from '@map-colonies/mc-priority-queue'; +import { ICreateJobBody, IJobResponse, ITaskResponse, OperationStatus } from '@map-colonies/mc-priority-queue'; import { Polygon, MultiPolygon } from '@turf/helpers'; import { BBox2d } from '@turf/helpers/dist/js/lib/geojson'; @@ -104,4 +104,5 @@ export interface ITaskParameters { } export type JobResponse = IJobResponse; +export type TaskResponse = ITaskResponse; export type CreateJobBody = ICreateJobBody; diff --git a/src/containerConfig.ts b/src/containerConfig.ts index fe4b5e0..dac96c5 100644 --- a/src/containerConfig.ts +++ b/src/containerConfig.ts @@ -8,6 +8,7 @@ import { SERVICES, SERVICE_NAME } from './common/constants'; import { tracing } from './common/tracing'; import { createPackageRouterFactory, CREATE_PACKAGE_ROUTER_SYMBOL } from './createPackage/routes/createPackageRouter'; import { InjectionObject, registerDependencies } from './common/dependencyRegistration'; +import { tasksRouterFactory, TASKS_ROUTER_SYMBOL } from './createPackage/routes/tasksRouter'; export interface RegisterOptions { override?: InjectionObject[]; @@ -31,6 +32,7 @@ export const registerExternalValues = (options?: RegisterOptions): DependencyCon { token: SERVICES.TRACER, provider: { useValue: tracer } }, { token: SERVICES.METER, provider: { useValue: meter } }, { token: CREATE_PACKAGE_ROUTER_SYMBOL, provider: { useFactory: createPackageRouterFactory } }, + { token: TASKS_ROUTER_SYMBOL, provider: { useFactory: tasksRouterFactory } }, { token: 'onSignal', provider: { diff --git a/src/createPackage/controllers/tasksController.ts b/src/createPackage/controllers/tasksController.ts new file mode 100644 index 0000000..56fd9d6 --- /dev/null +++ b/src/createPackage/controllers/tasksController.ts @@ -0,0 +1,23 @@ +import { Logger } from '@map-colonies/js-logger'; +import { RequestHandler } from 'express'; +import httpStatus from 'http-status-codes'; +import { injectable, inject } from 'tsyringe'; +import { SERVICES } from '../../common/constants'; +import { TaskStatusResponse, TasksManager } from '../models/tasksManager'; + +type GetTaskByJobIdHandler = RequestHandler<{ jobId: string }, TaskStatusResponse, string>; + +@injectable() +export class TasksController { + public constructor(@inject(SERVICES.LOGGER) private readonly logger: Logger, @inject(TasksManager) private readonly taskManager: TasksManager) {} + + public getTaskStatusByJobId: GetTaskByJobIdHandler = async (req, res, next) => { + const jobId: string = req.params.jobId; + try { + const taskStatus = await this.taskManager.getTaskStatusByJobId(jobId); + return res.status(httpStatus.OK).json(taskStatus); + } catch (err) { + next(err); + } + }; +} diff --git a/src/createPackage/models/tasksManager.ts b/src/createPackage/models/tasksManager.ts new file mode 100644 index 0000000..f8f5af2 --- /dev/null +++ b/src/createPackage/models/tasksManager.ts @@ -0,0 +1,36 @@ +import { sep } from 'path'; +import { Logger } from '@map-colonies/js-logger'; +import { inject, injectable } from 'tsyringe'; +import { JobManagerWrapper } from '../../clients/jobManagerWrapper'; +import { SERVICES } from '../../common/constants'; +import { TaskResponse } from '../../common/interfaces'; +import { NotFoundError } from '@map-colonies/error-types'; +import { OperationStatus } from '@map-colonies/mc-priority-queue'; + +export type TaskStatusResponse = { + percentage: number | undefined; + status: OperationStatus; +}; + +@injectable() +export class TasksManager { + public constructor( + @inject(SERVICES.LOGGER) private readonly logger: Logger, + @inject(JobManagerWrapper) private readonly jobManagerClient: JobManagerWrapper + ) {} + + public async getTaskStatusByJobId(jobId: string): Promise { + this.logger.info(`Getting task status by jobId: ${jobId}`); + const tasks = await this.jobManagerClient.getTasksByJobId(jobId); + + if (!tasks || tasks?.length === 0) { + throw new NotFoundError(`jobId: ${jobId} is not exists`); + } + const task = tasks[0]; + const statusResponse: TaskStatusResponse = { + percentage: task.percentage, + status: task.status, + }; + return statusResponse; + } +} diff --git a/src/createPackage/routes/tasksRouter.ts b/src/createPackage/routes/tasksRouter.ts new file mode 100644 index 0000000..8ba8c33 --- /dev/null +++ b/src/createPackage/routes/tasksRouter.ts @@ -0,0 +1,17 @@ +import { Router } from 'express'; +import { FactoryFunction } from 'tsyringe'; +import { CreatePackageController } from '../controllers/createPackageController'; +import { TasksController } from '../controllers/tasksController'; + +const tasksRouterFactory: FactoryFunction = (dependencyContainer) => { + const router = Router(); + const controller = dependencyContainer.resolve(TasksController); + + router.get('/taskStatus/:jobId', controller.getTaskStatusByJobId); + + return router; +}; + +export const TASKS_ROUTER_SYMBOL = Symbol('tasksFactory'); + +export { tasksRouterFactory }; diff --git a/src/serverBuilder.ts b/src/serverBuilder.ts index 717028f..a0c9571 100644 --- a/src/serverBuilder.ts +++ b/src/serverBuilder.ts @@ -10,6 +10,7 @@ import httpLogger from '@map-colonies/express-access-log-middleware'; import { SERVICES } from './common/constants'; import { IConfig } from './common/interfaces'; import { CREATE_PACKAGE_ROUTER_SYMBOL } from './createPackage/routes/createPackageRouter'; +import { TASKS_ROUTER_SYMBOL } from './createPackage/routes/tasksRouter'; @injectable() export class ServerBuilder { @@ -18,7 +19,8 @@ export class ServerBuilder { public constructor( @inject(SERVICES.CONFIG) private readonly config: IConfig, @inject(SERVICES.LOGGER) private readonly logger: Logger, - @inject(CREATE_PACKAGE_ROUTER_SYMBOL) private readonly createPackageRouter: Router + @inject(CREATE_PACKAGE_ROUTER_SYMBOL) private readonly createPackageRouter: Router, + @inject(TASKS_ROUTER_SYMBOL) private readonly tasksRouter: Router ) { this.serverInstance = express(); } @@ -39,6 +41,7 @@ export class ServerBuilder { private buildRoutes(): void { this.serverInstance.use('/create', this.createPackageRouter); + this.serverInstance.use('/', this.tasksRouter); this.buildDocsRoutes(); } From 47bef2979e4d6ffd33034dccedf2489eb89f14a8 Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Wed, 10 Aug 2022 16:12:08 +0300 Subject: [PATCH 2/7] fix: linter issues --- src/createPackage/models/tasksManager.ts | 14 ++++++-------- src/createPackage/routes/tasksRouter.ts | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/createPackage/models/tasksManager.ts b/src/createPackage/models/tasksManager.ts index f8f5af2..b8d214a 100644 --- a/src/createPackage/models/tasksManager.ts +++ b/src/createPackage/models/tasksManager.ts @@ -1,16 +1,14 @@ -import { sep } from 'path'; import { Logger } from '@map-colonies/js-logger'; import { inject, injectable } from 'tsyringe'; -import { JobManagerWrapper } from '../../clients/jobManagerWrapper'; -import { SERVICES } from '../../common/constants'; -import { TaskResponse } from '../../common/interfaces'; -import { NotFoundError } from '@map-colonies/error-types'; import { OperationStatus } from '@map-colonies/mc-priority-queue'; +import { NotFoundError } from '@map-colonies/error-types'; +import { SERVICES } from '../../common/constants'; +import { JobManagerWrapper } from '../../clients/jobManagerWrapper'; -export type TaskStatusResponse = { +export interface TaskStatusResponse { percentage: number | undefined; status: OperationStatus; -}; +} @injectable() export class TasksManager { @@ -23,7 +21,7 @@ export class TasksManager { this.logger.info(`Getting task status by jobId: ${jobId}`); const tasks = await this.jobManagerClient.getTasksByJobId(jobId); - if (!tasks || tasks?.length === 0) { + if (tasks.length === 0) { throw new NotFoundError(`jobId: ${jobId} is not exists`); } const task = tasks[0]; diff --git a/src/createPackage/routes/tasksRouter.ts b/src/createPackage/routes/tasksRouter.ts index 8ba8c33..837bbe5 100644 --- a/src/createPackage/routes/tasksRouter.ts +++ b/src/createPackage/routes/tasksRouter.ts @@ -1,6 +1,5 @@ import { Router } from 'express'; import { FactoryFunction } from 'tsyringe'; -import { CreatePackageController } from '../controllers/createPackageController'; import { TasksController } from '../controllers/tasksController'; const tasksRouterFactory: FactoryFunction = (dependencyContainer) => { From fca7c8b054c8e0771da86026093ab81a71453108 Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Wed, 10 Aug 2022 16:18:22 +0300 Subject: [PATCH 3/7] fix: linter issues --- openapi3.yaml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/openapi3.yaml b/openapi3.yaml index 3d0f3f1..4762504 100644 --- a/openapi3.yaml +++ b/openapi3.yaml @@ -93,21 +93,6 @@ components: application/json: schema: $ref: '#/components/schemas/exportGetMap' - getTasksByJobId: - description: get tasks by job id - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/exportGetMap' - parameters: - jobId: - in: path - name: jobId - description: ID of Job - required: true - schema: - $ref: '#/components/schemas/jobId' schemas: CommonResponse: type: object @@ -257,9 +242,6 @@ components: description: >- Bounding box corners (lower left, upper right)=[minx,miny,maxx,maxy] in crs units as array - jobId: - type: string - format: uuid getTaskStatusResponse: type: object properties: From 7bb4e76c24742063eb749bbd37f626d1e53d8a2b Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Sun, 14 Aug 2022 09:33:43 +0300 Subject: [PATCH 4/7] test: added tasks tests --- openapi3.yaml | 2 - .../controllers/tasksController.ts | 4 +- src/createPackage/models/tasksManager.ts | 6 +- .../createPackage/helpers/tasksSender.ts | 9 ++ tests/integration/createPackage/tasks.spec.ts | 89 +++++++++++++++++++ .../createPackage/models/tasksModel.spec.ts | 69 ++++++++++++++ 6 files changed, 172 insertions(+), 7 deletions(-) create mode 100644 tests/integration/createPackage/helpers/tasksSender.ts create mode 100644 tests/integration/createPackage/tasks.spec.ts create mode 100644 tests/unit/createPackage/models/tasksModel.spec.ts diff --git a/openapi3.yaml b/openapi3.yaml index 4762504..88df8dc 100644 --- a/openapi3.yaml +++ b/openapi3.yaml @@ -64,8 +64,6 @@ paths: application/json: schema: $ref: '#/components/schemas/getTaskStatusResponse' - discriminator: - propertyName: response '400': description: Bad Request content: diff --git a/src/createPackage/controllers/tasksController.ts b/src/createPackage/controllers/tasksController.ts index 56fd9d6..6a4545b 100644 --- a/src/createPackage/controllers/tasksController.ts +++ b/src/createPackage/controllers/tasksController.ts @@ -3,9 +3,9 @@ import { RequestHandler } from 'express'; import httpStatus from 'http-status-codes'; import { injectable, inject } from 'tsyringe'; import { SERVICES } from '../../common/constants'; -import { TaskStatusResponse, TasksManager } from '../models/tasksManager'; +import { ITaskStatusResponse, TasksManager } from '../models/tasksManager'; -type GetTaskByJobIdHandler = RequestHandler<{ jobId: string }, TaskStatusResponse, string>; +type GetTaskByJobIdHandler = RequestHandler<{ jobId: string }, ITaskStatusResponse, string>; @injectable() export class TasksController { diff --git a/src/createPackage/models/tasksManager.ts b/src/createPackage/models/tasksManager.ts index b8d214a..4100476 100644 --- a/src/createPackage/models/tasksManager.ts +++ b/src/createPackage/models/tasksManager.ts @@ -5,7 +5,7 @@ import { NotFoundError } from '@map-colonies/error-types'; import { SERVICES } from '../../common/constants'; import { JobManagerWrapper } from '../../clients/jobManagerWrapper'; -export interface TaskStatusResponse { +export interface ITaskStatusResponse { percentage: number | undefined; status: OperationStatus; } @@ -17,7 +17,7 @@ export class TasksManager { @inject(JobManagerWrapper) private readonly jobManagerClient: JobManagerWrapper ) {} - public async getTaskStatusByJobId(jobId: string): Promise { + public async getTaskStatusByJobId(jobId: string): Promise { this.logger.info(`Getting task status by jobId: ${jobId}`); const tasks = await this.jobManagerClient.getTasksByJobId(jobId); @@ -25,7 +25,7 @@ export class TasksManager { throw new NotFoundError(`jobId: ${jobId} is not exists`); } const task = tasks[0]; - const statusResponse: TaskStatusResponse = { + const statusResponse: ITaskStatusResponse = { percentage: task.percentage, status: task.status, }; diff --git a/tests/integration/createPackage/helpers/tasksSender.ts b/tests/integration/createPackage/helpers/tasksSender.ts new file mode 100644 index 0000000..960ea5f --- /dev/null +++ b/tests/integration/createPackage/helpers/tasksSender.ts @@ -0,0 +1,9 @@ +import * as supertest from 'supertest'; + +export class TasksSender { + public constructor(private readonly app: Express.Application) {} + + public async getTasksByJobId(jobId: string): Promise { + return supertest.agent(this.app).get(`/taskStatus/${jobId}`).set('Content-Type', 'application/json').send(); + } +} diff --git a/tests/integration/createPackage/tasks.spec.ts b/tests/integration/createPackage/tasks.spec.ts new file mode 100644 index 0000000..1312410 --- /dev/null +++ b/tests/integration/createPackage/tasks.spec.ts @@ -0,0 +1,89 @@ +import jsLogger from '@map-colonies/js-logger'; +import { trace } from '@opentelemetry/api'; +import httpStatusCodes from 'http-status-codes'; +import { container } from 'tsyringe'; +import { OperationStatus } from '@map-colonies/mc-priority-queue'; +import { getApp } from '../../../src/app'; +import { SERVICES } from '../../../src/common/constants'; +import { ITaskParameters, TaskResponse } from '../../../src/common/interfaces'; +import { JobManagerWrapper } from '../../../src/clients/jobManagerWrapper'; +import { TasksSender } from './helpers/tasksSender'; + +describe('tasks', function () { + let requestSender: TasksSender; + let getTasksByJobIdSpy: jest.SpyInstance; + + beforeEach(function () { + const app = getApp({ + override: [ + { token: SERVICES.LOGGER, provider: { useValue: jsLogger({ enabled: false }) } }, + { token: SERVICES.TRACER, provider: { useValue: trace.getTracer('testTracer') } }, + ], + useChild: true, + }); + requestSender = new TasksSender(app); + getTasksByJobIdSpy = jest.spyOn(JobManagerWrapper.prototype, 'getTasksByJobId'); + }); + + afterEach(function () { + container.clearInstances(); + jest.resetAllMocks(); + }); + + describe('Happy Path', function () { + it('should return 200 status code and the tasks matched the jobId', async function () { + const tasksResponse: TaskResponse[] = [ + { + id: '0a5552f7-01eb-40af-a912-eed8fa9e1561', + jobId: '0a5552f7-01eb-40af-a912-eed8fa9e1568', + type: 'rasterTilesExporterd', + description: '', + parameters: {} as unknown as ITaskParameters, + status: OperationStatus.IN_PROGRESS, + percentage: 23, + reason: '', + attempts: 0, + resettable: true, + created: '2022-08-02T13:02:18.475Z', + updated: '2022-08-02T15:01:56.658Z', + }, + ]; + const jobId = '09e29fa8-7283-4334-b3a4-99f75922de59'; + getTasksByJobIdSpy.mockResolvedValue(tasksResponse); + + const resposne = await requestSender.getTasksByJobId(jobId); + + expect(resposne).toSatisfyApiSpec(); + expect(getTasksByJobIdSpy).toHaveBeenCalledTimes(1); + expect(resposne.status).toBe(httpStatusCodes.OK); + }); + }); + + describe('Sad Path', function () { + it('should return 404 status code due to invalid string format (uuid)', async function () { + const tasksResponse: TaskResponse[] = []; + const jobId = '09e29fa8-7283-4334-b3a4-99f75922de59'; + getTasksByJobIdSpy.mockResolvedValue(tasksResponse); + + const resposne = await requestSender.getTasksByJobId(jobId); + + expect(resposne).toSatisfyApiSpec(); + expect(getTasksByJobIdSpy).toHaveBeenCalledTimes(1); + expect(resposne.status).toBe(httpStatusCodes.NOT_FOUND); + }); + }); + + describe('Bad Path', function () { + it('should return 400 status code when jobId is not exists', async function () { + const tasksResponse: TaskResponse[] = []; + const jobId = 'string'; + getTasksByJobIdSpy.mockResolvedValue(tasksResponse); + + const resposne = await requestSender.getTasksByJobId(jobId); + + expect(resposne).toSatisfyApiSpec(); + expect(getTasksByJobIdSpy).toHaveBeenCalledTimes(0); + expect(resposne.status).toBe(httpStatusCodes.BAD_REQUEST); + }); + }); +}); diff --git a/tests/unit/createPackage/models/tasksModel.spec.ts b/tests/unit/createPackage/models/tasksModel.spec.ts new file mode 100644 index 0000000..cf3aacd --- /dev/null +++ b/tests/unit/createPackage/models/tasksModel.spec.ts @@ -0,0 +1,69 @@ +import jsLogger from '@map-colonies/js-logger'; +import { OperationStatus } from '@map-colonies/mc-priority-queue'; +import { NotFoundError } from '@map-colonies/error-types'; +import { JobManagerWrapper } from '../../../../src/clients/jobManagerWrapper'; +import { ITaskStatusResponse, TasksManager } from '../../../../src/createPackage/models/tasksManager'; +import { ITaskParameters, TaskResponse } from '../../../../src/common/interfaces'; + + +let jobManagerWrapper: JobManagerWrapper; +let tasksManager: TasksManager; +let getTasksByJobIdStub: jest.Mock; + +describe('TasksManager', () => { + beforeEach(() => { + const logger = jsLogger({ enabled: false }); + jobManagerWrapper = new JobManagerWrapper(logger); + tasksManager = new TasksManager(logger, jobManagerWrapper); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.restoreAllMocks(); + }); + + describe('#getTaskStatusByJobId', async () => { + it('should throw NotFoundError when jobId is not exists', async () => { + const emptyTasksResponse: TaskResponse[] = []; + + getTasksByJobIdStub = jest.fn(); + jobManagerWrapper.getTasksByJobId = getTasksByJobIdStub.mockResolvedValue(emptyTasksResponse); + + const action = async () => tasksManager.getTaskStatusByJobId('09e29fa8-7283-4334-b3a4-99f75922de59'); + + expect(action).rejects.toThrow(NotFoundError); + expect(getTasksByJobIdStub).toHaveBeenCalledTimes(1); + }); + + it('should successfully return task status by jobId', async () => { + const tasksResponse: TaskResponse[] = [ + { + id: '0a5552f7-01eb-40af-a912-eed8fa9e1561', + jobId: '0a5552f7-01eb-40af-a912-eed8fa9e1568', + type: 'rasterTilesExporterd', + description: '', + parameters: {} as unknown as ITaskParameters, + status: OperationStatus.IN_PROGRESS, + percentage: 23, + reason: '', + attempts: 0, + resettable: true, + created: '2022-08-02T13:02:18.475Z', + updated: '2022-08-02T15:01:56.658Z', + }, + ]; + + getTasksByJobIdStub = jest.fn(); + jobManagerWrapper.getTasksByJobId = getTasksByJobIdStub.mockResolvedValue(tasksResponse); + + const result = tasksManager.getTaskStatusByJobId('0a5552f7-01eb-40af-a912-eed8fa9e1568'); + const expectedResult: ITaskStatusResponse = { + percentage: tasksResponse[0].percentage, + status: tasksResponse[0].status, + }; + await expect(result).resolves.not.toThrow(); + await expect(result).resolves.toEqual(expectedResult); + expect(getTasksByJobIdStub).toHaveBeenCalledTimes(1); + }); + }); +}); From 6c4b34cba43592a9dec1332729d96b130d445fc5 Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Sun, 14 Aug 2022 09:36:02 +0300 Subject: [PATCH 5/7] fix: prettier issues --- tests/unit/createPackage/models/tasksModel.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/createPackage/models/tasksModel.spec.ts b/tests/unit/createPackage/models/tasksModel.spec.ts index cf3aacd..9aa9714 100644 --- a/tests/unit/createPackage/models/tasksModel.spec.ts +++ b/tests/unit/createPackage/models/tasksModel.spec.ts @@ -5,7 +5,6 @@ import { JobManagerWrapper } from '../../../../src/clients/jobManagerWrapper'; import { ITaskStatusResponse, TasksManager } from '../../../../src/createPackage/models/tasksManager'; import { ITaskParameters, TaskResponse } from '../../../../src/common/interfaces'; - let jobManagerWrapper: JobManagerWrapper; let tasksManager: TasksManager; let getTasksByJobIdStub: jest.Mock; From 2b2ccb755f3194f0ca130e7f1da56b6c73f1bf1a Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Sun, 14 Aug 2022 09:37:10 +0300 Subject: [PATCH 6/7] fix: prettier issues --- tests/unit/createPackage/models/tasksModel.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/createPackage/models/tasksModel.spec.ts b/tests/unit/createPackage/models/tasksModel.spec.ts index 9aa9714..64703ac 100644 --- a/tests/unit/createPackage/models/tasksModel.spec.ts +++ b/tests/unit/createPackage/models/tasksModel.spec.ts @@ -21,7 +21,7 @@ describe('TasksManager', () => { jest.restoreAllMocks(); }); - describe('#getTaskStatusByJobId', async () => { + describe('#getTaskStatusByJobId', () => { it('should throw NotFoundError when jobId is not exists', async () => { const emptyTasksResponse: TaskResponse[] = []; From 120fec1e78374df657bbc386a2d3c3608b132283 Mon Sep 17 00:00:00 2001 From: Shlomi Koncha Date: Sun, 14 Aug 2022 09:50:41 +0300 Subject: [PATCH 7/7] fix: prettier issues --- tests/unit/createPackage/models/tasksModel.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/createPackage/models/tasksModel.spec.ts b/tests/unit/createPackage/models/tasksModel.spec.ts index 64703ac..9ed9a27 100644 --- a/tests/unit/createPackage/models/tasksModel.spec.ts +++ b/tests/unit/createPackage/models/tasksModel.spec.ts @@ -30,7 +30,7 @@ describe('TasksManager', () => { const action = async () => tasksManager.getTaskStatusByJobId('09e29fa8-7283-4334-b3a4-99f75922de59'); - expect(action).rejects.toThrow(NotFoundError); + await expect(action).rejects.toThrow(NotFoundError); expect(getTasksByJobIdStub).toHaveBeenCalledTimes(1); });