summaryrefslogtreecommitdiff
path: root/std/node/_fs
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2020-03-15 12:03:25 +0000
committerGitHub <noreply@github.com>2020-03-15 13:03:25 +0100
commit6471d4cfabf27c0f5e7b340568aa88712d270541 (patch)
tree29ca29b6baeb4715a0b7eeb24aeaf8b0ed112e97 /std/node/_fs
parent2f4be6e9441c7d5b0afd0d37dccd48d3057bcd3f (diff)
refactor(std): Uncomment disabled tests, use skip option (#4378)
Diffstat (limited to 'std/node/_fs')
-rw-r--r--std/node/_fs/_fs_chmod_test.ts85
-rw-r--r--std/node/_fs/_fs_chown_test.ts86
2 files changed, 88 insertions, 83 deletions
diff --git a/std/node/_fs/_fs_chmod_test.ts b/std/node/_fs/_fs_chmod_test.ts
index 9be6669f2..42c29cdc8 100644
--- a/std/node/_fs/_fs_chmod_test.ts
+++ b/std/node/_fs/_fs_chmod_test.ts
@@ -3,47 +3,6 @@ const { test } = Deno;
import { fail, assert } from "../../testing/asserts.ts";
import { chmod, chmodSync } from "./_fs_chmod.ts";
-if (Deno.build.os !== "win") {
- test({
- name: "ASYNC: Permissions are changed (non-Windows)",
- async fn() {
- const tempFile: string = await Deno.makeTempFile();
- const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode;
- await new Promise((resolve, reject) => {
- chmod(tempFile, 0o777, err => {
- if (err) reject(err);
- else resolve();
- });
- })
- .then(() => {
- const newFileMode: number | null = Deno.lstatSync(tempFile).mode;
- assert(newFileMode && originalFileMode);
- assert(newFileMode === 33279 && newFileMode > originalFileMode);
- })
- .catch(() => {
- fail();
- })
- .finally(() => {
- Deno.removeSync(tempFile);
- });
- }
- });
-
- test({
- name: "SYNC: Permissions are changed (non-Windows)",
- fn() {
- const tempFile: string = Deno.makeTempFileSync();
- const originalFileMode: number | null = Deno.lstatSync(tempFile).mode;
- chmodSync(tempFile, "777");
-
- const newFileMode: number | null = Deno.lstatSync(tempFile).mode;
- assert(newFileMode && originalFileMode);
- assert(newFileMode === 33279 && newFileMode > originalFileMode);
- Deno.removeSync(tempFile);
- }
- });
-}
-
test({
name: "ASYNC: Error passed in callback function when bad mode passed in",
async fn() {
@@ -61,6 +20,7 @@ test({
});
}
});
+
test({
name: "SYNC: Error thrown when bad mode passed in",
fn() {
@@ -73,3 +33,46 @@ test({
assert(caughtError);
}
});
+
+const skip = Deno.build.os == "win";
+
+test({
+ skip,
+ name: "ASYNC: Permissions are changed (non-Windows)",
+ async fn() {
+ const tempFile: string = await Deno.makeTempFile();
+ const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode;
+ await new Promise((resolve, reject) => {
+ chmod(tempFile, 0o777, err => {
+ if (err) reject(err);
+ else resolve();
+ });
+ })
+ .then(() => {
+ const newFileMode: number | null = Deno.lstatSync(tempFile).mode;
+ assert(newFileMode && originalFileMode);
+ assert(newFileMode === 33279 && newFileMode > originalFileMode);
+ })
+ .catch(() => {
+ fail();
+ })
+ .finally(() => {
+ Deno.removeSync(tempFile);
+ });
+ }
+});
+
+test({
+ skip,
+ name: "SYNC: Permissions are changed (non-Windows)",
+ fn() {
+ const tempFile: string = Deno.makeTempFileSync();
+ const originalFileMode: number | null = Deno.lstatSync(tempFile).mode;
+ chmodSync(tempFile, "777");
+
+ const newFileMode: number | null = Deno.lstatSync(tempFile).mode;
+ assert(newFileMode && originalFileMode);
+ assert(newFileMode === 33279 && newFileMode > originalFileMode);
+ Deno.removeSync(tempFile);
+ }
+});
diff --git a/std/node/_fs/_fs_chown_test.ts b/std/node/_fs/_fs_chown_test.ts
index 51a463d88..f7b4a8cec 100644
--- a/std/node/_fs/_fs_chown_test.ts
+++ b/std/node/_fs/_fs_chown_test.ts
@@ -3,48 +3,50 @@ const { test } = Deno;
import { fail, assertEquals } from "../../testing/asserts.ts";
import { chown, chownSync } from "./_fs_chown.ts";
-if (Deno.build.os !== "win") {
- //chown is difficult to test. Best we can do is set the existing user id/group id again
- test({
- name: "ASYNC: setting existing uid/gid works as expected (non-Windows)",
- async fn() {
- const tempFile: string = await Deno.makeTempFile();
- const originalUserId: number | null = (await Deno.lstat(tempFile)).uid;
- const originalGroupId: number | null = (await Deno.lstat(tempFile)).gid;
- await new Promise((resolve, reject) => {
- chown(tempFile, originalUserId!, originalGroupId!, err => {
- if (err) reject(err);
- else resolve();
- });
+//chown is difficult to test. Best we can do is set the existing user id/group id again
+const skip = Deno.build.os == "win";
+
+test({
+ skip,
+ name: "ASYNC: setting existing uid/gid works as expected (non-Windows)",
+ async fn() {
+ const tempFile: string = await Deno.makeTempFile();
+ const originalUserId: number | null = (await Deno.lstat(tempFile)).uid;
+ const originalGroupId: number | null = (await Deno.lstat(tempFile)).gid;
+ await new Promise((resolve, reject) => {
+ chown(tempFile, originalUserId!, originalGroupId!, err => {
+ if (err) reject(err);
+ else resolve();
+ });
+ })
+ .then(() => {
+ const newUserId: number | null = Deno.lstatSync(tempFile).uid;
+ const newGroupId: number | null = Deno.lstatSync(tempFile).gid;
+ assertEquals(newUserId, originalUserId);
+ assertEquals(newGroupId, originalGroupId);
+ })
+ .catch(() => {
+ fail();
})
- .then(() => {
- const newUserId: number | null = Deno.lstatSync(tempFile).uid;
- const newGroupId: number | null = Deno.lstatSync(tempFile).gid;
- assertEquals(newUserId, originalUserId);
- assertEquals(newGroupId, originalGroupId);
- })
- .catch(() => {
- fail();
- })
- .finally(() => {
- Deno.removeSync(tempFile);
- });
- }
- });
+ .finally(() => {
+ Deno.removeSync(tempFile);
+ });
+ }
+});
- test({
- name: "SYNC: setting existing uid/gid works as expected (non-Windows)",
- fn() {
- const tempFile: string = Deno.makeTempFileSync();
- const originalUserId: number | null = Deno.lstatSync(tempFile).uid;
- const originalGroupId: number | null = Deno.lstatSync(tempFile).gid;
- chownSync(tempFile, originalUserId!, originalGroupId!);
+test({
+ skip,
+ name: "SYNC: setting existing uid/gid works as expected (non-Windows)",
+ fn() {
+ const tempFile: string = Deno.makeTempFileSync();
+ const originalUserId: number | null = Deno.lstatSync(tempFile).uid;
+ const originalGroupId: number | null = Deno.lstatSync(tempFile).gid;
+ chownSync(tempFile, originalUserId!, originalGroupId!);
- const newUserId: number | null = Deno.lstatSync(tempFile).uid;
- const newGroupId: number | null = Deno.lstatSync(tempFile).gid;
- assertEquals(newUserId, originalUserId);
- assertEquals(newGroupId, originalGroupId);
- Deno.removeSync(tempFile);
- }
- });
-}
+ const newUserId: number | null = Deno.lstatSync(tempFile).uid;
+ const newGroupId: number | null = Deno.lstatSync(tempFile).gid;
+ assertEquals(newUserId, originalUserId);
+ assertEquals(newGroupId, originalGroupId);
+ Deno.removeSync(tempFile);
+ }
+});