some naming/organization changes

This commit is contained in:
Collin Duncan 2022-02-11 13:20:15 +01:00
parent 2b9fa53c5f
commit 767a5930a6
No known key found for this signature in database
6 changed files with 11 additions and 11 deletions

View file

@ -0,0 +1,5 @@
import { Worker } from "../types"
export const work: Worker<undefined, void> = async (): Promise<void> => {
return
}

View file

@ -1,5 +0,0 @@
import { Worker } from "../types"
export const run: Worker<undefined, void> = async (): Promise<void> => {
return
}

View file

@ -21,11 +21,11 @@ export interface ReservationSchedulerInput
dateRange: { start: string; end: string } dateRange: { start: string; end: string }
} }
export const run: Worker<ReservationSchedulerInput, ReservationSchedulerResult> = async ( export const work: Worker<ReservationSchedulerInput, ReservationSchedulerResult> = async (
payload: ReservationSchedulerInput, payload: ReservationSchedulerInput,
): Promise<ReservationSchedulerResult> => { ): Promise<ReservationSchedulerResult> => {
Logger.instantiate('reservationScheduler', v4(), LogLevel.DEBUG) Logger.instantiate('reservationScheduler', v4(), LogLevel.DEBUG)
Logger.debug('Handling event', { payload }) Logger.debug('Handling reservation', { payload })
let reservationRequest: ReservationRequest let reservationRequest: ReservationRequest
try { try {
reservationRequest = validateJSONRequest(payload) reservationRequest = validateJSONRequest(payload)

View file

@ -1,6 +1,6 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ValidationError, ValidationErrorCode } from '../../src/common/request' import { ValidationError, ValidationErrorCode } from '../../src/common/request'
import { run, ReservationSchedulerInput, ReservationSchedulerResult } from '../../src/workers/reservationScheduler' import { work, ReservationSchedulerInput, ReservationSchedulerResult } from '../../src/workers/scheduler'
jest.mock('../../src/common/logger') jest.mock('../../src/common/logger')
@ -16,7 +16,7 @@ describe('reservationScheduler', () => {
opponent: { id: "123", name: "collin" } opponent: { id: "123", name: "collin" }
} }
await expect(run(payload)).resolves await expect(work(payload)).resolves
.toMatchObject<ReservationSchedulerResult>({ .toMatchObject<ReservationSchedulerResult>({
scheduledReservationRequest: { scheduledReservationRequest: {
reservationRequest: { reservationRequest: {
@ -38,7 +38,7 @@ describe('reservationScheduler', () => {
opponent: { id: "123", name: "collin" } opponent: { id: "123", name: "collin" }
} }
await expect(run(payload)).resolves.toMatchObject<ReservationSchedulerResult>({ await expect(work(payload)).resolves.toMatchObject<ReservationSchedulerResult>({
scheduledReservationRequest: { scheduledReservationRequest: {
reservationRequest: { reservationRequest: {
username: 'collin', username: 'collin',
@ -61,7 +61,7 @@ describe('reservationScheduler', () => {
opponent: { id: "123", name: "collin" } opponent: { id: "123", name: "collin" }
} }
await expect(run(payload)) await expect(work(payload))
.rejects .rejects
.toThrowError(new ValidationError('Invalid request', ValidationErrorCode.INVALID_REQUEST_BODY)) .toThrowError(new ValidationError('Invalid request', ValidationErrorCode.INVALID_REQUEST_BODY))
}) })