From 668b400ff2fa5634f575e54f40ab1f0b78fcdf16 Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Mon, 11 Oct 2021 21:21:18 +0800 Subject: feat(runtime): improve error messages of runtime fs (#11984) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit annotates errors returned from FS Deno APIs to include paths that were passed to the API calls. Co-authored-by: Bartek IwaƄczuk --- cli/tests/unit/files_test.ts | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'cli/tests/unit/files_test.ts') diff --git a/cli/tests/unit/files_test.ts b/cli/tests/unit/files_test.ts index 410c89de9..9f5812d32 100644 --- a/cli/tests/unit/files_test.ts +++ b/cli/tests/unit/files_test.ts @@ -2,7 +2,13 @@ // deno-lint-ignore-file no-deprecated-deno-api -import { assert, assertEquals, assertRejects, unitTest } from "./test_util.ts"; +import { + assert, + assertEquals, + assertRejects, + assertThrows, + unitTest, +} from "./test_util.ts"; import { copy } from "../../../test_util/std/io/util.ts"; unitTest(function filesStdioFileDescriptors() { @@ -361,6 +367,32 @@ unitTest( }, ); +unitTest( + { permissions: { write: true, read: true } }, + async function openNotFound() { + await assertRejects( + async () => { + await Deno.open("bad_file_name"); + }, + Deno.errors.NotFound, + `open 'bad_file_name'`, + ); + }, +); + +unitTest( + { permissions: { write: true, read: true } }, + function openSyncNotFound() { + assertThrows( + () => { + Deno.openSync("bad_file_name"); + }, + Deno.errors.NotFound, + `open 'bad_file_name'`, + ); + }, +); + unitTest( { permissions: { read: true, write: true } }, async function createFile() { -- cgit v1.2.3