diff options
author | Satya Rohith <me@satyarohith.com> | 2024-03-07 19:28:46 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 19:28:46 +0530 |
commit | 588dd5e66961999cfafd4504444e685629a92173 (patch) | |
tree | 1e64ad6f88e4d77f6d12d2e09f8b038563844b24 /tests/unit/test_util.ts | |
parent | 0fb67ce43ea828db17fefc8df0ef8ec30b1a25c3 (diff) |
fix(ext/node): http2.createServer (#22708)
Diffstat (limited to 'tests/unit/test_util.ts')
-rw-r--r-- | tests/unit/test_util.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/unit/test_util.ts b/tests/unit/test_util.ts index c73f52b15..ba9bf1839 100644 --- a/tests/unit/test_util.ts +++ b/tests/unit/test_util.ts @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import * as colors from "@std/fmt/colors.ts"; +import { assert } from "@std/assert/mod.ts"; export { colors }; import { join, resolve } from "@std/path/mod.ts"; export { @@ -85,3 +86,35 @@ export function tmpUnixSocketPath(): string { const folder = Deno.makeTempDirSync(); return join(folder, "socket"); } + +export async function curlRequest(args: string[]) { + const { success, stdout, stderr } = await new Deno.Command("curl", { + args, + stdout: "piped", + stderr: "piped", + }).output(); + const decoder = new TextDecoder(); + assert( + success, + `Failed to cURL ${args}: stdout\n\n${ + decoder.decode(stdout) + }\n\nstderr:\n\n${decoder.decode(stderr)}`, + ); + return decoder.decode(stdout); +} + +export async function curlRequestWithStdErr(args: string[]) { + const { success, stdout, stderr } = await new Deno.Command("curl", { + args, + stdout: "piped", + stderr: "piped", + }).output(); + const decoder = new TextDecoder(); + assert( + success, + `Failed to cURL ${args}: stdout\n\n${ + decoder.decode(stdout) + }\n\nstderr:\n\n${decoder.decode(stderr)}`, + ); + return [decoder.decode(stdout), decoder.decode(stderr)]; +} |