Merge pull request #13788 from backstage/rugvip/blocking

backend-tasks: fix for fake timers blocking db setup
This commit is contained in:
Patrik Oldsberg
2022-09-21 19:11:40 +02:00
committed by GitHub
@@ -25,8 +25,6 @@ import {
PluginTaskSchedulerImpl,
} from './PluginTaskSchedulerImpl';
jest.useFakeTimers();
function defer() {
let resolve = () => {};
const promise = new Promise<void>(_resolve => {
@@ -40,6 +38,15 @@ describe('PluginTaskManagerImpl', () => {
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3'],
});
beforeAll(async () => {
// Make sure all databases are running before mocking timers, in case of testcontainers
await Promise.all(
databases.eachSupportedId().map(([id]) => databases.init(id)),
);
jest.useFakeTimers();
}, 30_000);
async function init(databaseId: TestDatabaseId) {
const knex = await databases.init(databaseId);
await migrateBackendTasks(knex);