2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-06 20:48:46 -05:00
|
|
|
import { test, testPerm, assert, assertEquals } from "./test_util.ts";
|
2018-08-30 13:49:24 -04:00
|
|
|
|
2019-01-13 09:39:23 -05:00
|
|
|
testPerm({ env: true }, function envSuccess() {
|
2019-02-12 10:08:56 -05:00
|
|
|
const env = Deno.env();
|
2018-08-31 07:51:12 -04:00
|
|
|
assert(env !== null);
|
2019-03-09 12:30:38 -05:00
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
2018-08-31 07:51:12 -04:00
|
|
|
env.test_var = "Hello World";
|
2019-02-12 10:08:56 -05:00
|
|
|
const newEnv = Deno.env();
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(env.test_var, newEnv.test_var);
|
2018-08-31 07:51:12 -04:00
|
|
|
});
|
|
|
|
|
2019-01-13 09:39:23 -05:00
|
|
|
test(function envFailure() {
|
2018-08-31 07:51:12 -04:00
|
|
|
let caughtError = false;
|
|
|
|
try {
|
2019-03-09 12:30:38 -05:00
|
|
|
Deno.env();
|
2018-08-31 07:51:12 -04:00
|
|
|
} catch (err) {
|
|
|
|
caughtError = true;
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
|
|
|
|
assertEquals(err.name, "PermissionDenied");
|
2018-08-31 07:51:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(caughtError);
|
|
|
|
});
|
2019-01-06 14:16:42 -05:00
|
|
|
|
|
|
|
test(function osPid() {
|
2019-02-12 10:08:56 -05:00
|
|
|
console.log("pid", Deno.pid);
|
|
|
|
assert(Deno.pid > 0);
|
2019-01-06 14:16:42 -05:00
|
|
|
});
|
2019-02-02 22:05:30 -05:00
|
|
|
|
|
|
|
// See complete tests in tools/is_tty_test.py
|
|
|
|
test(function osIsTTYSmoke() {
|
2019-02-12 10:08:56 -05:00
|
|
|
console.log(Deno.isTTY());
|
2019-02-02 22:05:30 -05:00
|
|
|
});
|