From 8a3be693c41fcea2bc384d13fa727aa418b871d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=98=81=EC=9A=B0?= Date: Wed, 3 Jul 2024 10:48:41 +0900 Subject: [PATCH] =?UTF-8?q?test:=20E2E=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=99=B8=EB=9E=98=ED=82=A4=20=EC=A0=9C=EC=95=BD?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=82=AD=EC=A0=9C=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=EB=A5=BC=20=EB=B0=A9=EC=A7=80=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 테이블을 삭제할때 해당 테이블의 행을 참조하는 다른 테이블의 행이 있어도 테이블 삭제가 가능하도록 FOREIGN_KEY_CHECKS 변수를 0으로 설정 - 테이블 삭제 후 모두 FOREIGN_KEY_CHECKS변수를 1로 설정 --- backend/test/setup.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/test/setup.ts b/backend/test/setup.ts index 7bedc06..b504b17 100644 --- a/backend/test/setup.ts +++ b/backend/test/setup.ts @@ -165,11 +165,13 @@ beforeAll(async () => { beforeEach(async () => { dataSource = app.get(DataSource); + await dataSource.query('SET FOREIGN_KEY_CHECKS = 0'); const entities = dataSource.entityMetadatas; for (const entity of entities) { const repository = dataSource.getRepository(entity.name); await repository.query(`DELETE FROM \`${entity.tableName}\``); } + await dataSource.query('SET FOREIGN_KEY_CHECKS = 1'); }); afterAll(async () => {