diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2018-09-11 09:00:57 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-09-11 12:00:57 -0400 |
commit | 05f87a0cf23a370c0009db8343b3770b518799c8 (patch) | |
tree | b2279e3257382ea1c1ec8c259e9fecdac9e78820 /js/os_test.ts | |
parent | c2663e1d82521e9b68a7e2e96197030a4ee00c30 (diff) |
Move writeFileSync to write_file.ts, add writeFile and tests (#728)
Diffstat (limited to 'js/os_test.ts')
-rw-r--r-- | js/os_test.ts | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/js/os_test.ts b/js/os_test.ts index df88b5085..4c5da1505 100644 --- a/js/os_test.ts +++ b/js/os_test.ts @@ -85,35 +85,6 @@ test(async function lstatSyncNotFound() { assertEqual(badInfo, undefined); }); -testPerm({ write: true }, function writeFileSyncSuccess() { - const enc = new TextEncoder(); - const data = enc.encode("Hello"); - const filename = deno.makeTempDirSync() + "/test.txt"; - deno.writeFileSync(filename, data, 0o666); - const dataRead = deno.readFileSync(filename); - const dec = new TextDecoder("utf-8"); - const actual = dec.decode(dataRead); - assertEqual("Hello", actual); -}); - -// For this test to pass we need --allow-write permission. -// Otherwise it will fail with deno.PermissionDenied instead of deno.NotFound. -testPerm({ write: true }, function writeFileSyncFail() { - const enc = new TextEncoder(); - const data = enc.encode("Hello"); - const filename = "/baddir/test.txt"; - // The following should fail because /baddir doesn't exist (hopefully). - let caughtError = false; - try { - deno.writeFileSync(filename, data); - } catch (e) { - caughtError = true; - assertEqual(e.kind, deno.ErrorKind.NotFound); - assertEqual(e.name, "NotFound"); - } - assert(caughtError); -}); - testPerm({ write: true }, function makeTempDirSync() { const dir1 = deno.makeTempDirSync({ prefix: "hello", suffix: "world" }); const dir2 = deno.makeTempDirSync({ prefix: "hello", suffix: "world" }); |