Skip to content

Commit

Permalink
sequentially run in test-utils
Browse files Browse the repository at this point in the history
queryrunner is not 'thread-safe' or async safe
  • Loading branch information
imnotjames committed Sep 20, 2020
1 parent e87f1cf commit 9d5d4df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ export async function createTestingConnections(options?: TestingOptions): Promis
});

const queryRunner = connection.createQueryRunner();
await Promise.all(databases.map(database => queryRunner.createDatabase(database, true)));

for (const database of databases) {
await queryRunner.createDatabase(database, true);
}

// create new schemas
if (connection.driver instanceof PostgresDriver || connection.driver instanceof SqlServerDriver) {
Expand All @@ -268,7 +271,9 @@ export async function createTestingConnections(options?: TestingOptions): Promis
if (schema && schemaPaths.indexOf(schema) === -1)
schemaPaths.push(schema);

await Promise.all(schemaPaths.map(schemaPath => queryRunner.createSchema(schemaPath, true)));
for (const schemaPath of schemaPaths) {
await queryRunner.createSchema(schemaPath, true);
}
}

await queryRunner.release();
Expand Down

0 comments on commit 9d5d4df

Please sign in to comment.