Skip to content

Commit ba92c9e

Browse files
committed
test: E2E테스트에서 외래키 제약조건으로 인한 테이블 삭제 실패를 방지하는 로직 추가
- 테이블을 삭제할때 해당 테이블의 행을 참조하는 다른 테이블의 행이 있어도 테이블 삭제가 가능하도록 FOREIGN_KEY_CHECKS 변수를 0으로 설정 - 테이블 삭제 후 모두 FOREIGN_KEY_CHECKS변수를 1로 설정
1 parent 3fc6345 commit ba92c9e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

backend/test/setup.ts

+2
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ beforeAll(async () => {
165165

166166
beforeEach(async () => {
167167
dataSource = app.get(DataSource);
168+
await dataSource.query('SET FOREIGN_KEY_CHECKS = 0');
168169
const entities = dataSource.entityMetadatas;
169170
for (const entity of entities) {
170171
const repository = dataSource.getRepository(entity.name);
171172
await repository.query(`DELETE FROM \`${entity.tableName}\``);
172173
}
174+
await dataSource.query('SET FOREIGN_KEY_CHECKS = 1');
173175
});
174176

175177
afterAll(async () => {

0 commit comments

Comments
 (0)