Skip to content

Commit

Permalink
fix: broken unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
jiho-kr committed Mar 2, 2024
1 parent 4751b33 commit 466a801
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/embedded-entities/embedded-entites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import request from 'supertest';

import { EmbeddedEntitiesModule } from './embedded-entities.module';
import { EmployeeEntity } from './employee.entity';
import { EmployeeService } from './employee.service';
import { UserEntity } from './user.entity';
import { TestHelper } from '../test.helper';

Expand All @@ -19,6 +20,9 @@ describe('Embedded-entities', () => {
});

afterAll(async () => {
const repository = app.get<EmployeeService>(EmployeeService).repository;
await repository.query('DROP TABLE IF EXISTS user_entity');
await repository.query('DROP TABLE IF EXISTS employee_entity');
await app?.close();
});

Expand Down
4 changes: 4 additions & 0 deletions spec/naming-strategy/embedded-entites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import request from 'supertest';
import { SnakeNamingStrategy } from './snake-naming.strategy';
import { EmbeddedEntitiesModule } from '../embedded-entities/embedded-entities.module';
import { EmployeeEntity } from '../embedded-entities/employee.entity';
import { EmployeeService } from '../embedded-entities/employee.service';
import { UserEntity } from '../embedded-entities/user.entity';
import { TestHelper } from '../test.helper';

Expand All @@ -20,6 +21,9 @@ describe('Embedded-entities using NamingStrategy', () => {
});

afterAll(async () => {
const repository = app.get<EmployeeService>(EmployeeService).repository;
await repository.query('DROP TABLE IF EXISTS user_entity');
await repository.query('DROP TABLE IF EXISTS employee_entity');
await app?.close();
});

Expand Down
3 changes: 3 additions & 0 deletions spec/test.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export class TestHelper {
const tables = [...metadata.tables];
while (tables.length > 0) {
const table = tables.shift()!;
if (!table.name) {
return;
}
const entity = table.target as typeof BaseEntity;

await entity.query(`DROP TABLE ${table.name}`).catch((error) => {
Expand Down

0 comments on commit 466a801

Please sign in to comment.