diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-25 01:12:22 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 15:12:22 +0100 |
commit | 4af121687cb4c26f4a2f3e4ad266490d8faa3d2d (patch) | |
tree | 97647feb4b94dd91d84e75499712d406cf151cf3 /cli/tests/unit_node/_fs/_fs_fsync_test.ts | |
parent | 064a6c048ab420302cbb822bedd3fc365b4259a7 (diff) |
feat: deprecate `Deno.ftruncate()` and `Deno.ftruncateSync()` (#22069)
For removal in Deno 2.0.
Diffstat (limited to 'cli/tests/unit_node/_fs/_fs_fsync_test.ts')
-rw-r--r-- | cli/tests/unit_node/_fs/_fs_fsync_test.ts | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_fsync_test.ts b/cli/tests/unit_node/_fs/_fs_fsync_test.ts index 3a0f51e7e..90bbed9da 100644 --- a/cli/tests/unit_node/_fs/_fs_fsync_test.ts +++ b/cli/tests/unit_node/_fs/_fs_fsync_test.ts @@ -5,32 +5,31 @@ import { fsync, fsyncSync } from "node:fs"; Deno.test({ name: "ASYNC: flush any pending data of the given file stream to disk", async fn() { - const file: string = await Deno.makeTempFile(); - const { rid } = await Deno.open(file, { + const filePath = await Deno.makeTempFile(); + using file = await Deno.open(filePath, { read: true, write: true, create: true, }); const size = 64; - await Deno.ftruncate(rid, size); + await file.truncate(size); await new Promise<void>((resolve, reject) => { - fsync(rid, (err: Error | null) => { + fsync(file.rid, (err: Error | null) => { if (err !== null) reject(); else resolve(); }); }) .then( async () => { - assertEquals((await Deno.stat(file)).size, size); + assertEquals((await Deno.stat(filePath)).size, size); }, () => { fail("No error expected"); }, ) .finally(async () => { - await Deno.remove(file); - Deno.close(rid); + await Deno.remove(filePath); }); }, }); @@ -38,21 +37,20 @@ Deno.test({ Deno.test({ name: "SYNC: flush any pending data the given file stream to disk", fn() { - const file: string = Deno.makeTempFileSync(); - const { rid } = Deno.openSync(file, { + const filePath = Deno.makeTempFileSync(); + using file = Deno.openSync(filePath, { read: true, write: true, create: true, }); const size = 64; - Deno.ftruncateSync(rid, size); + file.truncateSync(size); try { - fsyncSync(rid); - assertEquals(Deno.statSync(file).size, size); + fsyncSync(file.rid); + assertEquals(Deno.statSync(filePath).size, size); } finally { - Deno.removeSync(file); - Deno.close(rid); + Deno.removeSync(filePath); } }, }); |