fix: route the #124/#125 test files through tmp()
This commit is contained in:
parent
1acf172cad
commit
bf0dfd8fca
4 changed files with 12 additions and 20 deletions
|
|
@ -229,6 +229,8 @@ actually cutting it, and this file starts there.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- `tmp-guard` is green again: three test files from #124/#125 used raw `mkdtempSync`
|
||||||
|
|
||||||
- **A PR that deletes a shipped release heading is now CI-red** (#133,
|
- **A PR that deletes a shipped release heading is now CI-red** (#133,
|
||||||
heavy-duty/box#122) — `.github/scripts/changelog-monotonic.sh` asserts that
|
heavy-duty/box#122) — `.github/scripts/changelog-monotonic.sh` asserts that
|
||||||
the set of `## X.Y.Z` headings on HEAD is a superset of the set at the merge
|
the set of `## X.Y.Z` headings on HEAD is a superset of the set at the merge
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { execFileSync, spawn } from "node:child_process";
|
import { execFileSync, spawn } from "node:child_process";
|
||||||
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
import { mkdirSync, writeFileSync } from "node:fs";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
import type { AddressInfo } from "node:net";
|
import type { AddressInfo } from "node:net";
|
||||||
import { tmpdir } from "node:os";
|
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||||
|
import { tmp } from "./helpers/tmp.js";
|
||||||
|
|
||||||
// HTTP basic auth on an application, end to end: manifest -> the real binary ->
|
// HTTP basic auth on an application, end to end: manifest -> the real binary ->
|
||||||
// what goes on the wire and what reaches the terminal (cast#76).
|
// what goes on the wire and what reaches the terminal (cast#76).
|
||||||
|
|
@ -28,7 +28,7 @@ let recipient: string;
|
||||||
let keyFile: string;
|
let keyFile: string;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const dir = mkdtempSync(join(tmpdir(), "cast-age-"));
|
const dir = tmp("cast-age-");
|
||||||
keyFile = join(dir, "age.key");
|
keyFile = join(dir, "age.key");
|
||||||
execFileSync("age-keygen", ["-o", keyFile], { stdio: "pipe" });
|
execFileSync("age-keygen", ["-o", keyFile], { stdio: "pipe" });
|
||||||
recipient = execFileSync("age-keygen", ["-y", keyFile], {
|
recipient = execFileSync("age-keygen", ["-y", keyFile], {
|
||||||
|
|
@ -150,11 +150,11 @@ environments:
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function fixture(url: string, store = `ADMIN_BASIC_AUTH=${PASSWORD}\n`) {
|
function fixture(url: string, store = `ADMIN_BASIC_AUTH=${PASSWORD}\n`) {
|
||||||
const checkout = mkdtempSync(join(tmpdir(), "cast-co-"));
|
const checkout = tmp("cast-co-");
|
||||||
mkdirSync(join(checkout, ".infra", "env"), { recursive: true });
|
mkdirSync(join(checkout, ".infra", "env"), { recursive: true });
|
||||||
writeFileSync(join(checkout, ".infra", "manifest.yaml"), MANIFEST);
|
writeFileSync(join(checkout, ".infra", "manifest.yaml"), MANIFEST);
|
||||||
|
|
||||||
const state = mkdtempSync(join(tmpdir(), "cast-state-"));
|
const state = tmp("cast-state-");
|
||||||
mkdirSync(join(state, "secrets"));
|
mkdirSync(join(state, "secrets"));
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(state, ".coolify.env"),
|
join(state, ".coolify.env"),
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import { generateKeyPairSync } from "node:crypto";
|
import { generateKeyPairSync } from "node:crypto";
|
||||||
import { mkdtempSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
import { readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
import type { AddressInfo } from "node:net";
|
import type { AddressInfo } from "node:net";
|
||||||
import { tmpdir } from "node:os";
|
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||||
|
import { tmp } from "./helpers/tmp.js";
|
||||||
|
|
||||||
// `cast github-app register` through the real CLI: argv parsing, the stdin-only
|
// `cast github-app register` through the real CLI: argv parsing, the stdin-only
|
||||||
// client secret, the team assert, the name resolved from state, the
|
// client secret, the team assert, the name resolved from state, the
|
||||||
|
|
@ -90,7 +90,7 @@ function fixture(
|
||||||
url: string,
|
url: string,
|
||||||
githubApps: string,
|
githubApps: string,
|
||||||
): { state: string; pem: string } {
|
): { state: string; pem: string } {
|
||||||
const state = mkdtempSync(join(tmpdir(), "cast-state-"));
|
const state = tmp("cast-state-");
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(state, ".coolify.env"),
|
join(state, ".coolify.env"),
|
||||||
`COOLIFY_BASE_URL="${url}"\nCOOLIFY_ACCESS_TOKEN="t"\n`,
|
`COOLIFY_BASE_URL="${url}"\nCOOLIFY_ACCESS_TOKEN="t"\n`,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
import { createVerify, generateKeyPairSync } from "node:crypto";
|
import { createVerify, generateKeyPairSync } from "node:crypto";
|
||||||
import {
|
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
||||||
existsSync,
|
|
||||||
mkdtempSync,
|
|
||||||
readFileSync,
|
|
||||||
statSync,
|
|
||||||
writeFileSync,
|
|
||||||
} from "node:fs";
|
|
||||||
import { tmpdir } from "node:os";
|
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||||
import { loadBindings } from "../src/bindings.js";
|
import { loadBindings } from "../src/bindings.js";
|
||||||
|
|
@ -34,6 +27,7 @@ import {
|
||||||
seedGithubAppBinding,
|
seedGithubAppBinding,
|
||||||
startManifestServer,
|
startManifestServer,
|
||||||
} from "../src/github-app.js";
|
} from "../src/github-app.js";
|
||||||
|
import { tmp } from "./helpers/tmp.js";
|
||||||
|
|
||||||
// WHAT THIS FILE DOES NOT TEST, said out loud because the issue asks for it
|
// WHAT THIS FILE DOES NOT TEST, said out loud because the issue asks for it
|
||||||
// (#7, "Testability boundary"):
|
// (#7, "Testability boundary"):
|
||||||
|
|
@ -64,10 +58,6 @@ beforeAll(() => {
|
||||||
}) as string;
|
}) as string;
|
||||||
});
|
});
|
||||||
|
|
||||||
function tmp(prefix: string): string {
|
|
||||||
return mkdtempSync(join(tmpdir(), prefix));
|
|
||||||
}
|
|
||||||
|
|
||||||
function creds(over: Partial<AppCredentials> = {}): AppCredentials {
|
function creds(over: Partial<AppCredentials> = {}): AppCredentials {
|
||||||
return {
|
return {
|
||||||
appId: 12345,
|
appId: 12345,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue