-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.test.ts
More file actions
54 lines (46 loc) · 1.97 KB
/
Copy pathinstall.test.ts
File metadata and controls
54 lines (46 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { test, expect, describe } from "bun:test";
const INSTALL_SCRIPT = "./install.sh";
async function runInstall(...args: string[]) {
const proc = Bun.spawn(["bash", INSTALL_SCRIPT, ...args], {
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr] = await Promise.all([
new Response(proc.stdout).text(),
new Response(proc.stderr).text(),
]);
const exitCode = await proc.exited;
return { stdout, stderr, exitCode };
}
describe("install.sh flag validation", () => {
test("--version without a value exits with error", async () => {
const { stderr, exitCode } = await runInstall("--version");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--version requires a value");
});
test("--version followed by another flag exits with error", async () => {
const { stderr, exitCode } = await runInstall("--version", "--canary");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--version requires a value");
});
test("--install-dir without a value exits with error", async () => {
const { stderr, exitCode } = await runInstall("--install-dir");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--install-dir requires a value");
});
test("--install-dir followed by another flag exits with error", async () => {
const { stderr, exitCode } = await runInstall("--install-dir", "--local");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--install-dir requires a value");
});
test("--artifacts-dir without a value exits with error", async () => {
const { stderr, exitCode } = await runInstall("--artifacts-dir");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--artifacts-dir requires a value");
});
test("--artifacts-dir followed by another flag exits with error", async () => {
const { stderr, exitCode } = await runInstall("--artifacts-dir", "--canary");
expect(exitCode).not.toBe(0);
expect(stderr).toContain("--artifacts-dir requires a value");
});
});