diff options
author | await-ovo <13152410380@163.com> | 2023-07-17 21:10:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 22:10:34 +0900 |
commit | 37241e9b1e2d16cd160d529e69c6a782fff8a8b4 (patch) | |
tree | 20f85d17b7d6b6ac4957dc78b5d07182bc8efaf0 /cli/tests/unit_node/stream_test.ts | |
parent | 306b51d7728a6e28461171d3332a0b3aa8545a6e (diff) |
fix(ext/node): fix stream/promises export (#19820)
Diffstat (limited to 'cli/tests/unit_node/stream_test.ts')
-rw-r--r-- | cli/tests/unit_node/stream_test.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/tests/unit_node/stream_test.ts b/cli/tests/unit_node/stream_test.ts new file mode 100644 index 000000000..058d3ca7c --- /dev/null +++ b/cli/tests/unit_node/stream_test.ts @@ -0,0 +1,25 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +import { assert } from "../../../test_util/std/testing/asserts.ts"; +import { fromFileUrl, relative } from "../../../test_util/std/path/mod.ts"; +import { pipeline } from "node:stream/promises"; +import { createReadStream, createWriteStream } from "node:fs"; + +Deno.test("stream/promises pipeline", async () => { + const filePath = relative( + Deno.cwd(), + fromFileUrl(new URL("./testdata/lorem_ipsum.txt", import.meta.url)), + ); + const input = createReadStream(filePath); + const output = createWriteStream("lorem_ipsum.txt.copy"); + + await pipeline(input, output); + + const content = Deno.readTextFileSync("lorem_ipsum.txt.copy"); + assert(content.startsWith("Lorem ipsum dolor sit amet")); + try { + Deno.removeSync("lorem_ipsum.txt.copy"); + } catch { + // pass + } +}); |