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/truncate_test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cli/tests/unit/truncate_test.ts') diff --git a/cli/tests/unit/truncate_test.ts b/cli/tests/unit/truncate_test.ts index 19a44dba9..33a1cd4b1 100644 --- a/cli/tests/unit/truncate_test.ts +++ b/cli/tests/unit/truncate_test.ts @@ -91,3 +91,31 @@ unitTest({ permissions: { write: false } }, async function truncatePerm() { await Deno.truncate("/test_truncatePermission.txt"); }, Deno.errors.PermissionDenied); }); + +unitTest( + { permissions: { read: true, write: true } }, + function truncateSyncNotFound() { + const filename = "/badfile.txt"; + assertThrows( + () => { + Deno.truncateSync(filename); + }, + Deno.errors.NotFound, + `truncate '${filename}'`, + ); + }, +); + +unitTest( + { permissions: { read: true, write: true } }, + async function truncateSyncNotFound() { + const filename = "/badfile.txt"; + await assertRejects( + async () => { + await Deno.truncate(filename); + }, + Deno.errors.NotFound, + `truncate '${filename}'`, + ); + }, +); -- cgit v1.2.3