test(lanes): clean up fake-gh bin tmpdirs after ci/status tests
This commit is contained in:
@@ -934,13 +934,14 @@ describe("GET /:id/ci/status", () => {
|
|||||||
let laneId;
|
let laneId;
|
||||||
let laneCwd;
|
let laneCwd;
|
||||||
let restorePath;
|
let restorePath;
|
||||||
|
let bin;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
laneCwd = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-route-"));
|
laneCwd = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-route-"));
|
||||||
const r = await request("POST", "/api/lanes", { title: "CI status lane", cwd: laneCwd });
|
const r = await request("POST", "/api/lanes", { title: "CI status lane", cwd: laneCwd });
|
||||||
laneId = r.body.lane.id;
|
laneId = r.body.lane.id;
|
||||||
|
|
||||||
const bin = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-bin-"));
|
bin = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-bin-"));
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(bin, "gh"),
|
path.join(bin, "gh"),
|
||||||
`#!/usr/bin/env bash
|
`#!/usr/bin/env bash
|
||||||
@@ -966,6 +967,7 @@ exit 1
|
|||||||
after(() => {
|
after(() => {
|
||||||
if (restorePath) restorePath();
|
if (restorePath) restorePath();
|
||||||
fs.rmSync(laneCwd, { recursive: true, force: true });
|
fs.rmSync(laneCwd, { recursive: true, force: true });
|
||||||
|
fs.rmSync(bin, { recursive: true, force: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("404s for an unknown lane", async () => {
|
it("404s for an unknown lane", async () => {
|
||||||
|
|||||||
@@ -545,9 +545,10 @@ describe("ccam lanes — inferred stage detection", () => {
|
|||||||
|
|
||||||
describe("ccam lanes ci status", () => {
|
describe("ccam lanes ci status", () => {
|
||||||
let restorePath;
|
let restorePath;
|
||||||
|
let bin;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
const bin = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-cli-bin-"));
|
bin = fs.mkdtempSync(path.join(os.tmpdir(), "ccam-ci-status-cli-bin-"));
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(bin, "gh"),
|
path.join(bin, "gh"),
|
||||||
`#!/usr/bin/env bash
|
`#!/usr/bin/env bash
|
||||||
@@ -580,7 +581,10 @@ exit 1
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => restorePath && restorePath());
|
after(() => {
|
||||||
|
if (restorePath) restorePath();
|
||||||
|
fs.rmSync(bin, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
it("exits 0 and prints success state", async () => {
|
it("exits 0 and prints success state", async () => {
|
||||||
const r = await cli(["lanes", "ci", "status", "development"], LANE_DIR);
|
const r = await cli(["lanes", "ci", "status", "development"], LANE_DIR);
|
||||||
|
|||||||
Reference in New Issue
Block a user