mirror of
https://github.com/denoland/deno.git
synced 2024-10-31 09:14:20 -04:00
24 lines
666 B
TypeScript
24 lines
666 B
TypeScript
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
|
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
|
|
import * as deno from "deno";
|
|
|
|
testPerm({ env: true }, async function envSuccess() {
|
|
const env = deno.env();
|
|
assert(env !== null);
|
|
env.test_var = "Hello World";
|
|
const newEnv = deno.env();
|
|
assertEqual(env.test_var, newEnv.test_var);
|
|
});
|
|
|
|
test(async function envFailure() {
|
|
let caughtError = false;
|
|
try {
|
|
const env = deno.env();
|
|
} catch (err) {
|
|
caughtError = true;
|
|
assertEqual(err.kind, deno.ErrorKind.PermissionDenied);
|
|
assertEqual(err.name, "PermissionDenied");
|
|
}
|
|
|
|
assert(caughtError);
|
|
});
|