summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/_fs/_fs_fdatasync_test.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-25 01:59:55 +1100
committerGitHub <noreply@github.com>2024-01-24 15:59:55 +0100
commit62786cfebb5c9fe36d0930582951f442bdfe9441 (patch)
treea1bede5492a5b1bf4a202ee8994df027f098e788 /cli/tests/unit_node/_fs/_fs_fdatasync_test.ts
parent4af121687cb4c26f4a2f3e4ad266490d8faa3d2d (diff)
feat: deprecate `Deno.close()` (#22066)
For removal in Deno v2. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tests/unit_node/_fs/_fs_fdatasync_test.ts')
-rw-r--r--cli/tests/unit_node/_fs/_fs_fdatasync_test.ts26
1 files changed, 12 insertions, 14 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_fdatasync_test.ts b/cli/tests/unit_node/_fs/_fs_fdatasync_test.ts
index 7ea42a512..6a58eba12 100644
--- a/cli/tests/unit_node/_fs/_fs_fdatasync_test.ts
+++ b/cli/tests/unit_node/_fs/_fs_fdatasync_test.ts
@@ -6,32 +6,31 @@ Deno.test({
name:
"ASYNC: flush any pending data operations 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 data = new Uint8Array(64);
- await Deno.write(rid, data);
+ await Deno.write(file.rid, data);
await new Promise<void>((resolve, reject) => {
- fdatasync(rid, (err: Error | null) => {
+ fdatasync(file.rid, (err: Error | null) => {
if (err !== null) reject();
else resolve();
});
})
.then(
async () => {
- assertEquals(await Deno.readFile(file), data);
+ assertEquals(await Deno.readFile(filePath), data);
},
() => {
fail("No error expected");
},
)
.finally(async () => {
- Deno.close(rid);
- await Deno.remove(file);
+ await Deno.remove(filePath);
});
},
});
@@ -40,21 +39,20 @@ Deno.test({
name:
"SYNC: flush any pending data operations of 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 data = new Uint8Array(64);
- Deno.writeSync(rid, data);
+ Deno.writeSync(file.rid, data);
try {
- fdatasyncSync(rid);
- assertEquals(Deno.readFileSync(file), data);
+ fdatasyncSync(file.rid);
+ assertEquals(Deno.readFileSync(filePath), data);
} finally {
- Deno.close(rid);
- Deno.removeSync(file);
+ Deno.removeSync(filePath);
}
},
});