aboutsummaryrefslogtreecommitdiff
path: root/test/js/bun/io/bun-write.test.js
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-10-14 12:58:30 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-10-14 12:58:30 -0700
commitf9add8b6bea4df3cdbd56a21f17e4cab1a854e4e (patch)
tree8e5306104d81c67b771181337bba02cd9ec39453 /test/js/bun/io/bun-write.test.js
parent81a1a58d66c598ea35c42453d0ba4c6341a940fc (diff)
parent9b5e66453b0879ed77b71dcdbe50e4efa184261e (diff)
downloadbun-sdl.tar.gz
bun-sdl.tar.zst
bun-sdl.zip
Merge branch 'main' into sdlsdl
Diffstat (limited to '')
-rw-r--r--test/js/bun/io/bun-write.test.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/js/bun/io/bun-write.test.js b/test/js/bun/io/bun-write.test.js
index a05fa283a..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) {