diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-09-21 15:18:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 15:18:58 +0900 |
commit | cc32a297da2d92983573a1cea1ca669d6139d77d (patch) | |
tree | 3c63367faf9594969b07bfcc8d11f6018ecc2b6e /cli | |
parent | 35fe9ee530b389f9249a7eccc2b0f91dc3cb414e (diff) |
fix(runtime): better error message with Deno.env.get/set (#15966)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/tests/unit/os_test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts index 3564ffa47..bdbf7f0ca 100644 --- a/cli/tests/unit/os_test.ts +++ b/cli/tests/unit/os_test.ts @@ -116,6 +116,40 @@ Deno.test( }, ); +Deno.test({ permissions: { env: true } }, function envInvalidChars() { + assertThrows(() => Deno.env.get(""), TypeError, "Key is an empty string"); + assertThrows( + () => Deno.env.get("\0"), + TypeError, + 'Key contains invalid characters: "\\0"', + ); + assertThrows( + () => Deno.env.get("="), + TypeError, + 'Key contains invalid characters: "="', + ); + assertThrows( + () => Deno.env.set("", "foo"), + TypeError, + "Key is an empty string", + ); + assertThrows( + () => Deno.env.set("\0", "foo"), + TypeError, + 'Key contains invalid characters: "\\0"', + ); + assertThrows( + () => Deno.env.set("=", "foo"), + TypeError, + 'Key contains invalid characters: "="', + ); + assertThrows( + () => Deno.env.set("foo", "\0"), + TypeError, + 'Value contains invalid characters: "\\0"', + ); +}); + Deno.test(function osPid() { assert(Deno.pid > 0); }); |