Files
medusa-store/integration-tests/factories/simple-batch-job-factory.ts.txt
Riqwan Thamir 0573bb924a chore: Remove typeORM (#9005)
* chore: rename js files to txt

* chore: rename ts files to txt

* chore: delete environment helpers

* chore: convert global setup & teardown to txt

* chore: rename helper js/ts files to txt

* chore: rename seeder js/ts files to txt

* chore: remove typeorm

* chore: reintroduce used helpers
2024-09-05 15:45:30 +02:00

31 lines
817 B
Plaintext

import { DataSource } from "typeorm"
import { BatchJob, BatchJobStatus } from "@medusajs/medusa"
export type BatchJobFactoryData = {
id?: string
type?: string
status?: BatchJobStatus
created_by?: string
context?: Record<string, unknown>
awaiting_confirmation_at?: Date | string
completed_at?: Date | string
}
export const simpleBatchJobFactory = async (
dataSource: DataSource,
data: BatchJobFactoryData = {}
): Promise<BatchJob> => {
const manager = dataSource.manager
const job = manager.create<BatchJob>(BatchJob, {
id: data.id,
status: data.status ?? BatchJobStatus.CREATED,
completed_at: data.completed_at ?? null,
type: data.type ?? "test-job",
created_by: data.created_by ?? null,
context: data.context ?? {},
})
return await manager.save<BatchJob>(job)
}