From e250b23b73c57a4d326dafea685fab0554271094 Mon Sep 17 00:00:00 2001 From: "zhangyongsheng.dev__dcar" Date: Wed, 15 Jan 2025 16:52:37 +0800 Subject: [PATCH] fix(ext/node): deno test --- tests/unit_node/_fs/_fs_handle_test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit_node/_fs/_fs_handle_test.ts b/tests/unit_node/_fs/_fs_handle_test.ts index d7ae32b5ea75f6..6bf37b6e0e7f49 100644 --- a/tests/unit_node/_fs/_fs_handle_test.ts +++ b/tests/unit_node/_fs/_fs_handle_test.ts @@ -300,3 +300,20 @@ Deno.test({ await fileHandle.close(); }, }); + +Deno.test({ + name: + "[node/fs filehandle.sync] Request that all data for the open file descriptor is flushed to the storage device", + async fn() { + const fileHandle = await fs.open(testData, "r+"); + + await fileHandle.datasync(); + await fileHandle.sync(); + const buf = Buffer.from("hello world"); + await fileHandle.write(buf); + const ret = await fileHandle.read(Buffer.alloc(11), 0, 11, 0); + assertEquals(ret.bytesRead, 11); + assertEquals(ret.buffer, buf); + await fileHandle.close(); + }, +});