refactor: remove unneeded ErrorKinds (#3936)

This commit is contained in:
Bartek Iwańczuk 2020-02-21 10:36:13 -05:00 committed by GitHub
parent d9efb8c02a
commit dd8a109481
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 553 additions and 620 deletions

View file

@ -18,8 +18,7 @@ testPerm({ write: true, read: true }, function removeSyncDirSuccess(): void {
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm({ write: true, read: true }, function removeSyncFileSuccess(): void {
@ -39,8 +38,7 @@ testPerm({ write: true, read: true }, function removeSyncFileSuccess(): void {
err = e;
}
// File is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm({ write: true, read: true }, function removeSyncFail(): void {
@ -61,8 +59,7 @@ testPerm({ write: true, read: true }, function removeSyncFail(): void {
err = e;
}
// TODO(ry) Is Other really the error we should get here? What would Go do?
assertEquals(err.kind, Deno.ErrorKind.Other);
assertEquals(err.name, "Other");
assert(err instanceof Error);
// NON-EXISTENT DIRECTORY/FILE
try {
// Non-existent
@ -70,8 +67,7 @@ testPerm({ write: true, read: true }, function removeSyncFail(): void {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm(
@ -86,7 +82,6 @@ testPerm(
errOnWindows = err;
}
if (Deno.build.os === "win") {
assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEquals(errOnWindows.message, "Not implemented");
} else {
const pathInfo = Deno.lstatSync(danglingSymlinkPath);
@ -98,8 +93,7 @@ testPerm(
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
}
);
@ -121,7 +115,6 @@ testPerm(
errOnWindows = err;
}
if (Deno.build.os === "win") {
assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEquals(errOnWindows.message, "Not implemented");
} else {
const symlinkPathInfo = Deno.statSync(validSymlinkPath);
@ -134,8 +127,7 @@ testPerm(
err = e;
}
Deno.removeSync(filePath);
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
}
);
@ -147,7 +139,7 @@ testPerm({ write: false }, function removeSyncPerm(): void {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assert(err instanceof Deno.Err.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});
@ -166,8 +158,8 @@ testPerm({ write: true, read: true }, function removeAllSyncDirSuccess(): void {
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
// REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir";
const subPath = path + "/subsubdir";
@ -185,8 +177,7 @@ testPerm({ write: true, read: true }, function removeAllSyncDirSuccess(): void {
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm(
@ -208,8 +199,7 @@ testPerm(
err = e;
}
// File is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
);
@ -222,8 +212,7 @@ testPerm({ write: true }, function removeAllSyncFail(): void {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm({ write: false }, function removeAllSyncPerm(): void {
@ -233,7 +222,7 @@ testPerm({ write: false }, function removeAllSyncPerm(): void {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assert(err instanceof Deno.Err.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});
@ -256,8 +245,7 @@ testPerm(
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
);
@ -280,8 +268,7 @@ testPerm(
err = e;
}
// File is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
);
@ -304,8 +291,7 @@ testPerm({ write: true, read: true }, async function removeFail(): Promise<
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.Other);
assertEquals(err.name, "Other");
assert(err instanceof Error);
// NON-EXISTENT DIRECTORY/FILE
try {
// Non-existent
@ -313,8 +299,7 @@ testPerm({ write: true, read: true }, async function removeFail(): Promise<
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm(
@ -329,7 +314,6 @@ testPerm(
errOnWindows = e;
}
if (Deno.build.os === "win") {
assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEquals(errOnWindows.message, "Not implemented");
} else {
const pathInfo = Deno.lstatSync(danglingSymlinkPath);
@ -341,8 +325,7 @@ testPerm(
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
}
);
@ -364,7 +347,6 @@ testPerm(
errOnWindows = e;
}
if (Deno.build.os === "win") {
assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEquals(errOnWindows.message, "Not implemented");
} else {
const symlinkPathInfo = Deno.statSync(validSymlinkPath);
@ -377,8 +359,7 @@ testPerm(
err = e;
}
Deno.removeSync(filePath);
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
}
);
@ -390,7 +371,7 @@ testPerm({ write: false }, async function removePerm(): Promise<void> {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assert(err instanceof Deno.Err.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});
@ -411,8 +392,8 @@ testPerm(
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
// REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir";
const subPath = path + "/subsubdir";
@ -430,8 +411,7 @@ testPerm(
err = e;
}
// Directory is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
);
@ -454,8 +434,7 @@ testPerm(
err = e;
}
// File is gone
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
}
);
@ -468,8 +447,7 @@ testPerm({ write: true }, async function removeAllFail(): Promise<void> {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEquals(err.name, "NotFound");
assert(err instanceof Deno.Err.NotFound);
});
testPerm({ write: false }, async function removeAllPerm(): Promise<void> {
@ -479,6 +457,6 @@ testPerm({ write: false }, async function removeAllPerm(): Promise<void> {
} catch (e) {
err = e;
}
assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assert(err instanceof Deno.Err.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});