diff options
| author | 2023-10-17 14:10:25 -0700 | |
|---|---|---|
| committer | 2023-10-17 14:10:25 -0700 | |
| commit | 7458b969c5d9971e89d187b687e1924e78da427e (patch) | |
| tree | ee3dbf95c728cf407bf49a27826b541e9264a8bd /test/js/bun/io/bun-write.test.js | |
| parent | d4a2c29131ec154f5e4db897d4deedab2002cbc4 (diff) | |
| parent | e91436e5248d947b50f90b4a7402690be8a41f39 (diff) | |
| download | bun-7458b969c5d9971e89d187b687e1924e78da427e.tar.gz bun-7458b969c5d9971e89d187b687e1924e78da427e.tar.zst bun-7458b969c5d9971e89d187b687e1924e78da427e.zip | |
Merge branch 'main' into postinstall_3
Diffstat (limited to 'test/js/bun/io/bun-write.test.js')
| -rw-r--r-- | test/js/bun/io/bun-write.test.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/js/bun/io/bun-write.test.js b/test/js/bun/io/bun-write.test.js index f435d2ceb..fbcc99b66 100644 --- a/test/js/bun/io/bun-write.test.js +++ b/test/js/bun/io/bun-write.test.js @@ -80,6 +80,31 @@ it("Bun.file not found returns ENOENT", async () => { await gcTick(); }); +it("Bun.write file not found returns ENOENT, issue#6336", async () => { + const dst = Bun.file(path.join(tmpdir(), "does/not/exist.txt")); + try { + await gcTick(); + await Bun.write(dst, ""); + await gcTick(); + } catch (exception) { + expect(exception.code).toBe("ENOENT"); + expect(exception.path).toBe(dst.name); + } + + const src = Bun.file(path.join(tmpdir(), `test-bun-write-${Date.now()}.txt`)); + await Bun.write(src, ""); + try { + await gcTick(); + await Bun.write(dst, src); + await gcTick(); + } catch (exception) { + expect(exception.code).toBe("ENOENT"); + expect(exception.path).toBe(dst.name); + } finally { + fs.unlinkSync(src.name); + } +}); + it("Bun.write('out.txt', 'string')", async () => { for (let erase of [true, false]) { if (erase) { @@ -300,6 +325,16 @@ it("offset should work #4963", async () => { expect(contents).toBe("ntents"); }); +it("length should be limited by file size #5080", async () => { + const filename = tmpdir() + "/bun.test.offset2.txt"; + await Bun.write(filename, "contents"); + const file = Bun.file(filename); + const slice = file.slice(2, 1024); + const contents = await slice.text(); + expect(contents).toBe("ntents"); + expect(contents.length).toBeLessThanOrEqual(file.size); +}); + it("#2674", async () => { const file = path.join(import.meta.dir, "big-stdout.js"); |
