From dd1e6500639c25d73ff63dd8fde6ba093b2b4255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Sun, 19 Mar 2023 01:01:50 +0100 Subject: fix(runtime): Extract error code for all OS error variants (#17958) --- cli/tests/unit/read_file_test.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/read_file_test.ts b/cli/tests/unit/read_file_test.ts index 24cf6dccf..5761cb1cb 100644 --- a/cli/tests/unit/read_file_test.ts +++ b/cli/tests/unit/read_file_test.ts @@ -158,3 +158,29 @@ Deno.test( assert(data.byteLength > 0); }, ); + +Deno.test( + { permissions: { read: true } }, + async function readFileNotFoundErrorCode() { + try { + await Deno.readFile("definitely-not-found.json"); + } catch (e) { + assertEquals(e.code, "ENOENT"); + } + }, +); + +Deno.test( + { permissions: { read: true } }, + async function readFileIsDirectoryErrorCode() { + try { + await Deno.readFile("cli/tests/testdata/assets/"); + } catch (e) { + if (Deno.build.os === "windows") { + assertEquals(e.code, "ENOENT"); + } else { + assertEquals(e.code, "EISDIR"); + } + } + }, +); -- cgit v1.2.3