diff options
author | Kamil Ogórek <kamil.ogorek@gmail.com> | 2023-03-19 01:01:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-19 00:01:50 +0000 |
commit | dd1e6500639c25d73ff63dd8fde6ba093b2b4255 (patch) | |
tree | b4a380793d44daab2190b2a423e61b35a20639a8 /cli | |
parent | b64ec7926831896f4e43b685891111409de45e85 (diff) |
fix(runtime): Extract error code for all OS error variants (#17958)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/tests/unit/read_file_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
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"); + } + } + }, +); |