diff options
author | Chris Knight <cknight1234@gmail.com> | 2020-03-16 11:40:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 12:40:36 +0100 |
commit | 62942749e6982b9aee24c22a5abdbc44b7f0e6b6 (patch) | |
tree | 25b813a005268787326d02c0d975c7daf8162d0e | |
parent | 1edb20b399944c6eec1d7c555ab170b6dd276840 (diff) |
test: Fix broken test and remove redundant test file (#4390)
-rwxr-xr-x | std/node/fs_test.ts | 113 | ||||
-rw-r--r-- | std/node/module_test.ts | 2 |
2 files changed, 1 insertions, 114 deletions
diff --git a/std/node/fs_test.ts b/std/node/fs_test.ts deleted file mode 100755 index 96d0f6597..000000000 --- a/std/node/fs_test.ts +++ /dev/null @@ -1,113 +0,0 @@ -const { test } = Deno; -import { readFile, readFileSync, readlink, readlinkSync } from "./fs.ts"; -import * as path from "../path/mod.ts"; -import { assertEquals, assert } from "../testing/asserts.ts"; - -const testData = path.resolve(path.join("node", "testdata", "hello.txt")); -const testDir = Deno.makeTempDirSync(); -const oldname = testDir + "/oldname"; -const newname = testDir + "/newname"; - -// Need to convert to promises, otherwise test() won't report error correctly. -test(async function readFileSuccess() { - const data = await new Promise((res, rej) => { - readFile(testData, (err, data) => { - if (err) { - rej(err); - } - res(data); - }); - }); - - assert(data instanceof Uint8Array); - assertEquals(new TextDecoder().decode(data as Uint8Array), "hello world"); -}); - -test(async function readFileEncodeUtf8Success() { - const data = await new Promise((res, rej) => { - readFile(testData, { encoding: "utf8" }, (err, data) => { - if (err) { - rej(err); - } - res(data); - }); - }); - - assertEquals(typeof data, "string"); - assertEquals(data as string, "hello world"); -}); - -test(function readFileSyncSuccess() { - const data = readFileSync(testData); - assert(data instanceof Uint8Array); - assertEquals(new TextDecoder().decode(data as Uint8Array), "hello world"); -}); - -test(function readFileEncodeUtf8Success() { - const data = readFileSync(testData, { encoding: "utf8" }); - assertEquals(typeof data, "string"); - assertEquals(data as string, "hello world"); -}); - -// Just for now, until we implement symlink for Windows. -const skip = Deno.build.os == "win"; - -if (!skip) { - Deno.symlinkSync(oldname, newname); -} - -test({ - skip, - name: "readlinkSuccess", - async fn() { - const data = await new Promise((res, rej) => { - readlink(newname, (err, data) => { - if (err) { - rej(err); - } - res(data); - }); - }); - - assertEquals(typeof data, "string"); - assertEquals(data as string, oldname); - } -}); - -test({ - skip, - name: "readlinkEncodeBufferSuccess", - async fn() { - const data = await new Promise((res, rej) => { - readlink(newname, { encoding: "buffer" }, (err, data) => { - if (err) { - rej(err); - } - res(data); - }); - }); - - assert(data instanceof Uint8Array); - assertEquals(new TextDecoder().decode(data as Uint8Array), oldname); - } -}); - -test({ - skip, - name: "readlinkSyncSuccess", - fn() { - const data = readlinkSync(newname); - assertEquals(typeof data, "string"); - assertEquals(data as string, oldname); - } -}); - -test({ - skip, - name: "readlinkEncodeBufferSuccess", - fn() { - const data = readlinkSync(newname, { encoding: "buffer" }); - assert(data instanceof Uint8Array); - assertEquals(new TextDecoder().decode(data as Uint8Array), oldname); - } -}); diff --git a/std/node/module_test.ts b/std/node/module_test.ts index 7415f1845..6de5bd66e 100644 --- a/std/node/module_test.ts +++ b/std/node/module_test.ts @@ -31,7 +31,7 @@ test(function requireBuiltin() { assert("readFileSync" in fs); const { readFileSync, isNull, extname } = require_("./tests/cjs/cjs_builtin"); assertEquals( - readFileSync("./node/testdata/hello.txt", { encoding: "utf8" }), + readFileSync("./node/_fs/testdata/hello.txt", { encoding: "utf8" }), "hello world" ); assert(isNull(null)); |