tests: add case for invalid inputs in fresh-init (#276)
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
co-authored by
Luca Casonato
parent
76d5423b90
commit
56ecfcc7ee
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
assertEquals,
|
assertEquals,
|
||||||
|
assertStringIncludes,
|
||||||
delay,
|
delay,
|
||||||
puppeteer,
|
puppeteer,
|
||||||
TextLineStream,
|
TextLineStream,
|
||||||
@@ -290,3 +291,61 @@ Deno.test({
|
|||||||
sanitizeOps: false,
|
sanitizeOps: false,
|
||||||
sanitizeResources: false,
|
sanitizeResources: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("fresh-init error(help)", async function (t) {
|
||||||
|
const includeText = "fresh-init";
|
||||||
|
|
||||||
|
await t.step(
|
||||||
|
"execute invalid init command (deno run -A init.ts)",
|
||||||
|
async () => {
|
||||||
|
const cliProcess = Deno.run({
|
||||||
|
cmd: ["deno", "run", "-A", "init.ts"],
|
||||||
|
stderr: "piped",
|
||||||
|
});
|
||||||
|
const { code } = await cliProcess.status();
|
||||||
|
cliProcess.close();
|
||||||
|
assertEquals(code, 1);
|
||||||
|
|
||||||
|
const rawError = await cliProcess.stderrOutput();
|
||||||
|
const errorString = new TextDecoder().decode(rawError);
|
||||||
|
|
||||||
|
assertStringIncludes(errorString, includeText);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await t.step(
|
||||||
|
"execute invalid init command (deno run -A init.ts -f)",
|
||||||
|
async () => {
|
||||||
|
const cliProcess = Deno.run({
|
||||||
|
cmd: ["deno", "run", "-A", "init.ts", "-f"],
|
||||||
|
stderr: "piped",
|
||||||
|
});
|
||||||
|
const { code } = await cliProcess.status();
|
||||||
|
cliProcess.close();
|
||||||
|
assertEquals(code, 1);
|
||||||
|
|
||||||
|
const rawError = await cliProcess.stderrOutput();
|
||||||
|
const errorString = new TextDecoder().decode(rawError);
|
||||||
|
|
||||||
|
assertStringIncludes(errorString, includeText);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await t.step(
|
||||||
|
"execute invalid init command (deno run -A init.ts --foo)",
|
||||||
|
async () => {
|
||||||
|
const cliProcess = Deno.run({
|
||||||
|
cmd: ["deno", "run", "-A", "init.ts", "--foo"],
|
||||||
|
stderr: "piped",
|
||||||
|
});
|
||||||
|
const { code } = await cliProcess.status();
|
||||||
|
cliProcess.close();
|
||||||
|
assertEquals(code, 1);
|
||||||
|
|
||||||
|
const rawError = await cliProcess.stderrOutput();
|
||||||
|
const errorString = new TextDecoder().decode(rawError);
|
||||||
|
|
||||||
|
assertStringIncludes(errorString, includeText);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user