From 6c3d97a7e2e52858ff3689e94eedc5733e8df0aa Mon Sep 17 00:00:00 2001 From: nguyener1 <61910221+nguyener1@users.noreply.github.com> Date: Tue, 26 Oct 2021 00:27:18 -0400 Subject: [PATCH] refactor: cleanup temp dir in test (#12319) --- lib/manager/cargo/extract.spec.ts | 8 +++++--- lib/manager/git-submodules/update.spec.ts | 8 +++++--- lib/manager/gradle/deep/index-real.spec.ts | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/manager/cargo/extract.spec.ts b/lib/manager/cargo/extract.spec.ts index e733510baa..585ed908e3 100644 --- a/lib/manager/cargo/extract.spec.ts +++ b/lib/manager/cargo/extract.spec.ts @@ -1,4 +1,4 @@ -import { dir } from 'tmp-promise'; +import { DirectoryResult, dir } from 'tmp-promise'; import { join } from 'upath'; import { loadFixture } from '../../../test/util'; import { setGlobalConfig } from '../../config/global'; @@ -19,10 +19,11 @@ describe('manager/cargo/extract', () => { describe('extractPackageFile()', () => { let config: ExtractConfig; let adminConfig: RepoGlobalConfig; + let tmpDir: DirectoryResult; beforeEach(async () => { config = {}; - const tmpDir = await dir(); + tmpDir = await dir({ unsafeCleanup: true }); adminConfig = { localDir: join(tmpDir.path, 'local'), cacheDir: join(tmpDir.path, 'cache'), @@ -30,7 +31,8 @@ describe('manager/cargo/extract', () => { setGlobalConfig(adminConfig); }); - afterEach(() => { + afterEach(async () => { + await tmpDir.cleanup(); setGlobalConfig(); }); it('returns null for invalid toml', async () => { diff --git a/lib/manager/git-submodules/update.spec.ts b/lib/manager/git-submodules/update.spec.ts index ef7e07bdaf..3e9b6c7f73 100644 --- a/lib/manager/git-submodules/update.spec.ts +++ b/lib/manager/git-submodules/update.spec.ts @@ -1,5 +1,5 @@ import _simpleGit from 'simple-git'; -import { dir } from 'tmp-promise'; +import { DirectoryResult, dir } from 'tmp-promise'; import { join } from 'upath'; import { setGlobalConfig } from '../../config/global'; import type { RepoGlobalConfig } from '../../config/types'; @@ -13,14 +13,16 @@ describe('manager/git-submodules/update', () => { describe('updateDependency', () => { let upgrade: Upgrade; let adminConfig: RepoGlobalConfig; + let tmpDir: DirectoryResult; beforeAll(async () => { upgrade = { depName: 'renovate' }; - const tmpDir = await dir(); + tmpDir = await dir({ unsafeCleanup: true }); adminConfig = { localDir: join(tmpDir.path) }; setGlobalConfig(adminConfig); }); - afterAll(() => { + afterAll(async () => { + await tmpDir.cleanup(); setGlobalConfig(); }); it('returns null on error', async () => { diff --git a/lib/manager/gradle/deep/index-real.spec.ts b/lib/manager/gradle/deep/index-real.spec.ts index 7903247d3d..d0bfcf894c 100644 --- a/lib/manager/gradle/deep/index-real.spec.ts +++ b/lib/manager/gradle/deep/index-real.spec.ts @@ -46,7 +46,8 @@ allprojects { successFile = `${workingDir.path}/${SUCCESS_FILE_NAME}`; }); - afterEach(() => { + afterEach(async () => { + await workingDir.cleanup(); setGlobalConfig(); }); -- GitLab