diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/node_unit_tests.rs | 1 | ||||
-rw-r--r-- | cli/tests/unit_node/stream_test.ts | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/integration/node_unit_tests.rs b/cli/tests/integration/node_unit_tests.rs index ddfeb3d50..b4fdbcf7b 100644 --- a/cli/tests/integration/node_unit_tests.rs +++ b/cli/tests/integration/node_unit_tests.rs @@ -73,6 +73,7 @@ util::unit_test_factory!( process_test, querystring_test, readline_test, + stream_test, string_decoder_test, timers_test, tls_test, 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 + } +}); |