diff --git a/tests/test-cases/gitlab-runner-emulation/integration.emulate-runner.test.ts b/tests/test-cases/gitlab-runner-emulation/integration.emulate-runner.test.ts index dd11a4d20..0b92cf758 100644 --- a/tests/test-cases/gitlab-runner-emulation/integration.emulate-runner.test.ts +++ b/tests/test-cases/gitlab-runner-emulation/integration.emulate-runner.test.ts @@ -2,12 +2,14 @@ import {WriteStreamsMock} from "../../../src/write-streams"; import {handler} from "../../../src/handler"; import {initBashSpy, initSpawnSpy} from "../../mocks/utils.mock"; import {WhenStatics} from "../../mocks/when-statics"; +import {cleanupJobResources, Job} from "../../../src/job"; import { GitlabRunnerCPUsPresetValue, GitlabRunnerMemoryPresetValue, GitlabRunnerPresetValues, } from "../../../src/gitlab-preset"; +let jobs: Job[] = []; beforeAll(() => { initSpawnSpy([...WhenStatics.all, { cmdArgs: ["docker", "cp", expect.any(String), expect.any(String)], @@ -15,13 +17,21 @@ beforeAll(() => { }]); }); +beforeEach(async () => { + jobs = []; +}); + +afterEach(async () => { + await cleanupJobResources(jobs); +}); + test("--container-emulate some_unexisting_runner", async () => { try { const writeStreams = new WriteStreamsMock(); await handler({ cwd: "tests/test-cases/container-executable", containerEmulate: "some_unexisting_runner", - }, writeStreams); + }, writeStreams, jobs); expect(true).toBe(false); } catch (e: unknown) { diff --git a/tests/test-cases/network-arg/integration.network-arg.test.ts b/tests/test-cases/network-arg/integration.network-arg.test.ts index 9a7ca87e6..ee63715a3 100644 --- a/tests/test-cases/network-arg/integration.network-arg.test.ts +++ b/tests/test-cases/network-arg/integration.network-arg.test.ts @@ -1,15 +1,24 @@ import {WriteStreamsMock} from "../../../src/write-streams"; import {handler} from "../../../src/handler"; +import {Job, cleanupJobResources} from "../../../src/job"; import chalk from "chalk"; import {initSpawnSpy, initBashSpy} from "../../mocks/utils.mock"; import {WhenStatics} from "../../mocks/when-statics"; import assert from "assert"; import {AssertionError} from "assert"; +let jobs: Job[] = []; beforeAll(() => { initSpawnSpy(WhenStatics.all); }); +beforeEach(async () => { + jobs = []; +}); + +afterEach(async () => { + await cleanupJobResources(jobs); +}); test("network-host ", async () => { const bashSpy = initBashSpy([]); @@ -36,7 +45,7 @@ test("network-host ", async () => { cwd: "tests/test-cases/network-arg", job: ["service-job"], network: ["host"], - }, writeStreams); + }, writeStreams, jobs); } catch (e) { assert(e instanceof AssertionError, "e is not instanceof AssertionError"); expect(e.message).toBe(chalk`Cannot add service network alias with network mode 'host'`); @@ -68,7 +77,7 @@ test("network-none ", async () => { cwd: "tests/test-cases/network-arg", job: ["service-job"], network: ["none"], - }, writeStreams); + }, writeStreams, jobs); } catch (e) { assert(e instanceof AssertionError, "e is not instanceof AssertionError"); expect(e.message).toBe(chalk`Cannot add service network alias with network mode 'none'`);