From 63191a3b61465db57714de281832e35c25596f5a Mon Sep 17 00:00:00 2001 From: "SAITO-PC-3\\saito.k" Date: Wed, 14 Feb 2024 12:06:19 +0900 Subject: [PATCH] =?UTF-8?q?OptionItem=E3=81=AE=E4=BD=9C=E6=88=90=E3=81=8C?= =?UTF-8?q?=E9=87=8D=E8=A4=87=E3=81=97=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E7=89=87=E6=96=B9?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=20=E3=82=BF=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?Mysql=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/features/tasks/tasks.service.spec.ts | 34 ++++++++---- .../src/features/tasks/test/utility.ts | 53 ------------------- 2 files changed, 23 insertions(+), 64 deletions(-) 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 }; };