-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Fix: Data source changed for testing purposes"
This reverts commit c1affb6.
- Loading branch information
Showing
8 changed files
with
51 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import testDataSource from "../config/ormconfig.test"; | ||
import AppDataSource from "../config/ormconfig"; | ||
|
||
beforeAll(async () => { | ||
if (!testDataSource.isInitialized) { | ||
await testDataSource.initialize(); | ||
if (!AppDataSource.isInitialized) { | ||
await AppDataSource.initialize(); | ||
} | ||
|
||
await testDataSource.synchronize(); | ||
if (process.env.NODE_ENV === "test") { | ||
await AppDataSource.synchronize(); | ||
|
||
const queryRunner = AppDataSource.createQueryRunner(); | ||
const tables = await queryRunner.getTables(); | ||
await queryRunner.release(); | ||
} | ||
}); | ||
|
||
afterEach(async () => { | ||
const entities = testDataSource.entityMetadatas; | ||
const entities = AppDataSource.entityMetadatas; | ||
for (const entity of entities) { | ||
const repository = testDataSource.getRepository(entity.name); | ||
const repository = AppDataSource.getRepository(entity.name); | ||
await repository.clear(); | ||
} | ||
}); | ||
|
||
afterAll(async () => { | ||
if (testDataSource.isInitialized) { | ||
await testDataSource.destroy(); | ||
if (AppDataSource.isInitialized) { | ||
await AppDataSource.destroy(); | ||
} | ||
}); |