diff options
author | 2023-03-18 16:58:15 -0700 | |
---|---|---|
committer | 2023-03-18 16:58:15 -0700 | |
commit | 1b7423412ae7cf1b6303abe2ae8853070003518c (patch) | |
tree | ade847deab5cd111a1ab22abcc3e60bb2b130d24 /test/js/web/streams/streams.test.js | |
parent | 41c4a66e4aeee1182ce1f44b6aee6883717d3551 (diff) | |
download | bun-1b7423412ae7cf1b6303abe2ae8853070003518c.tar.gz bun-1b7423412ae7cf1b6303abe2ae8853070003518c.tar.zst bun-1b7423412ae7cf1b6303abe2ae8853070003518c.zip |
Make this test more thorough
Diffstat (limited to 'test/js/web/streams/streams.test.js')
-rw-r--r-- | test/js/web/streams/streams.test.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/js/web/streams/streams.test.js b/test/js/web/streams/streams.test.js index c4af85e4f..27b9b703f 100644 --- a/test/js/web/streams/streams.test.js +++ b/test/js/web/streams/streams.test.js @@ -1,4 +1,4 @@ -import { file, readableStreamToArrayBuffer, readableStreamToArray, readableStreamToText } from "bun"; +import { file, readableStreamToArrayBuffer, readableStreamToArray, readableStreamToText, ArrayBufferSink } from "bun"; import { expect, it, beforeEach, afterEach, describe } from "bun:test"; import { mkfifo } from "mkfifo"; import { realpathSync, unlinkSync, writeFileSync } from "node:fs"; @@ -613,7 +613,17 @@ it("Blob.stream() -> new Response(stream).text()", async () => { }); it("Bun.file().stream() read text from large file", async () => { - const hugely = "HELLO!".repeat(1024 * 1024 * 10); + // Guard against reading the same repeating chunks + // There were bugs previously where the stream would + // repeat the same chunk over and over again + var sink = new ArrayBufferSink(); + sink.start({ highWaterMark: 1024 * 1024 * 10 }); + var written = 0; + var i = 0; + while (written < 1024 * 1024 * 10) { + written += sink.write(Bun.SHA1.hash((i++).toString(10), "hex")); + } + const hugely = Buffer.from(sink.end()).toString(); const tmpfile = join(realpathSync(tmpdir()), "bun-streams-test.txt"); writeFileSync(tmpfile, hugely); try { |