mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
Fix open handles in tests (#4858)
## About the changes This fixes a bunch of openHandles from our tests I've used this script to find out the ones that leave them: `find src -name "*.test.ts" -printf "%f\n" | xargs -i sh -c "echo ===== {} && yarn test {}"` If there's an issue, the script will halt and the last filename will be the one that has to be fixed. Each commit fixes one problem so it's easy to review
This commit is contained in:
parent
f9c3259083
commit
93da4a1217
@ -102,6 +102,7 @@ beforeAll(async () => {
|
||||
|
||||
afterAll(async () => {
|
||||
await app.destroy();
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
@ -7,7 +7,7 @@ import { PublicSignupTokenCreateSchema } from '../../../../lib/openapi/spec/publ
|
||||
let stores;
|
||||
let db;
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
db = await dbInit('test', getLogger);
|
||||
stores = db.stores;
|
||||
});
|
||||
|
@ -31,6 +31,7 @@ beforeAll(async () => {
|
||||
afterAll(async () => {
|
||||
getLogger.setMuteError(false);
|
||||
await app.destroy();
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
test('should create a PAT', async () => {
|
||||
|
@ -61,7 +61,7 @@ beforeEach(async () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
afterEach(async () => {
|
||||
await app.destroy();
|
||||
await db.destroy();
|
||||
});
|
||||
|
@ -21,6 +21,10 @@ beforeAll(async () => {
|
||||
stores = db.stores;
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
test('Using custom auth type without defining custom middleware causes default DENY ALL policy to take effect', async () => {
|
||||
jest.spyOn(global.console, 'error').mockImplementation(() => jest.fn());
|
||||
const { request, destroy } = await setupAppWithCustomAuth(
|
||||
|
@ -216,10 +216,14 @@ async function createApp(
|
||||
const request = supertest.agent(app);
|
||||
|
||||
const destroy = async () => {
|
||||
services.versionService.destroy();
|
||||
services.clientInstanceService.destroy();
|
||||
services.clientMetricsServiceV2.destroy();
|
||||
services.proxyService.destroy();
|
||||
// iterate on the keys of services and if the services at that key has a function called destroy then call it
|
||||
await Promise.all(
|
||||
Object.keys(services).map(async (key) => {
|
||||
if (services[key].destroy) {
|
||||
await services[key].destroy();
|
||||
}
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
// TODO: use create from server-impl instead?
|
||||
|
Loading…
Reference in New Issue
Block a user