summaryrefslogtreecommitdiff
path: root/cli/tests/unit/http_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/http_test.ts')
-rw-r--r--cli/tests/unit/http_test.ts148
1 files changed, 74 insertions, 74 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 2a4b7df01..779f11e56 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -1165,11 +1165,13 @@ Deno.test(
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = ["curl", "-X", "DELETE", url];
- const proc = Deno.run({ cmd, stdout: "null", stderr: "null" });
- const status = await proc.status();
+ const args = ["-X", "DELETE", url];
+ const { status } = await Deno.spawn("curl", {
+ args,
+ stdout: "null",
+ stderr: "null",
+ });
assert(status.success);
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1277,8 +1279,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1287,13 +1288,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(output.includes("content-encoding: gzip\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1327,8 +1329,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"--request",
"GET",
"--url",
@@ -1336,10 +1337,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const proc = Deno.spawnChild("curl", { args, stderr: "null" });
+ const status = await proc.status;
assert(status.success);
- const stdout = proc.stdout!.readable
+ const stdout = proc.stdout
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream());
let body = "";
@@ -1347,7 +1348,6 @@ Deno.test({
body += chunk;
}
assertEquals(JSON.parse(body), data);
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1382,8 +1382,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1392,13 +1391,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output()).toLocaleLowerCase();
+ const output = decoder.decode(stdout).toLocaleLowerCase();
assert(output.includes("vary: accept-encoding\r\n"));
assert(!output.includes("content-encoding: "));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1436,8 +1436,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1446,13 +1445,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip;q=0.8, br;q=1.0, *;q=0.1",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(output.includes("content-encoding: br\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1487,8 +1487,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1497,13 +1496,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding, Accept\r\n"));
assert(output.includes("content-encoding: gzip\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1541,7 +1541,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
+ const args = [
"curl",
"-i",
"--request",
@@ -1551,16 +1551,17 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
);
assert(output.includes("content-encoding: gzip\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1598,8 +1599,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1608,16 +1608,17 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
);
assert(output.includes("content-encoding: gzip\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1655,8 +1656,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1665,13 +1665,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(!output.includes("content-encoding: "));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1709,8 +1710,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1719,13 +1719,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(!output.includes("content-encoding: "));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1768,7 +1769,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
+ const args = [
"curl",
"-i",
"--request",
@@ -1778,13 +1779,14 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(output.includes("content-encoding: gzip\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1827,8 +1829,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"--request",
"GET",
"--url",
@@ -1836,10 +1837,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const proc = Deno.spawnChild("curl", { args, stderr: "null" });
+ const status = await proc.status;
assert(status.success);
- const stdout = proc.stdout.readable
+ const stdout = proc.stdout
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream());
let body = "";
@@ -1847,7 +1848,6 @@ Deno.test({
body += chunk;
}
assertEquals(JSON.parse(body), data);
- proc.close();
}
await Promise.all([server(), client()]);
@@ -1892,8 +1892,7 @@ Deno.test({
async function client() {
const url = `http://${hostname}:${port}/`;
- const cmd = [
- "curl",
+ const args = [
"-i",
"--request",
"GET",
@@ -1902,16 +1901,17 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
- const status = await proc.status();
+ const { status, stdout } = await Deno.spawn("curl", {
+ args,
+ stderr: "null",
+ });
assert(status.success);
- const output = decoder.decode(await proc.output());
+ const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
assert(output.includes("content-encoding: gzip\r\n"));
// Ensure the content-length header is updated.
assert(!output.includes(`content-length: ${contentLength}\r\n`));
assert(output.includes("content-length: 72\r\n"));
- proc.close();
}
await Promise.all([server(), client()]);