diff --git a/dictation_server/src/features/tasks/tasks.service.spec.ts b/dictation_server/src/features/tasks/tasks.service.spec.ts index 2e1a101..54e191b 100644 --- a/dictation_server/src/features/tasks/tasks.service.spec.ts +++ b/dictation_server/src/features/tasks/tasks.service.spec.ts @@ -4120,20 +4120,32 @@ describe('getNextTask', () => { describe('deleteTask', () => { let source: DataSource | null = null; + beforeAll(async () => { + if (source == null) { + source = await (async () => { + const s = new DataSource({ + type: 'mysql', + host: 'test_mysql_db', + port: 3306, + username: 'user', + password: 'password', + database: 'odms', + entities: [__dirname + '/../../**/*.entity{.ts,.js}'], + synchronize: false, // trueにすると自動的にmigrationが行われるため注意 + }); + return await s.initialize(); + })(); + } + }); + beforeEach(async () => { - source = new DataSource({ - type: 'sqlite', - database: ':memory:', - logging: false, - entities: [__dirname + '/../../**/*.entity{.ts,.js}'], - synchronize: true, // trueにすると自動的にmigrationが行われるため注意 - }); - return source.initialize(); + if (source) { + await truncateAllTable(source); + } }); - afterEach(async () => { - if (!source) return; - await source.destroy(); + afterAll(async () => { + await source?.destroy(); source = null; }); diff --git a/dictation_server/src/features/tasks/test/utility.ts b/dictation_server/src/features/tasks/test/utility.ts index eb3938e..6a1e024 100644 --- a/dictation_server/src/features/tasks/test/utility.ts +++ b/dictation_server/src/features/tasks/test/utility.ts @@ -158,59 +158,6 @@ export const createTask = async ( }); const task = taskIdentifiers.pop() as Task; - await datasource.getRepository(AudioOptionItem).insert([ - { - audio_file_id: audioFile.id, - label: 'label01', - value: 'value01', - }, - { - audio_file_id: audioFile.id, - label: 'label02', - value: 'value02', - }, - { - audio_file_id: audioFile.id, - label: 'label03', - value: 'value03', - }, - { - audio_file_id: audioFile.id, - label: 'label04', - value: 'value04', - }, - { - audio_file_id: audioFile.id, - label: 'label05', - value: 'value05', - }, - { - audio_file_id: audioFile.id, - label: 'label06', - value: 'value06', - }, - { - audio_file_id: audioFile.id, - label: 'label07', - value: 'value07', - }, - { - audio_file_id: audioFile.id, - label: 'label08', - value: 'value08', - }, - { - audio_file_id: audioFile.id, - label: 'label09', - value: 'value09', - }, - { - audio_file_id: audioFile.id, - label: 'label10', - value: 'value10', - }, - ]); - return { taskId: task.id, audioFileId: audioFile.id }; };