mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 09:39:08 -05:00
chore(std/node/fs): Remove unnecessary try-catch (#8908)
This commit is contained in:
parent
115de4c81a
commit
0e0ffa417b
1 changed files with 15 additions and 52 deletions
|
@ -1,5 +1,9 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert } from "../../testing/asserts.ts";
|
||||
import {
|
||||
assert,
|
||||
assertThrows,
|
||||
assertThrowsAsync,
|
||||
} from "../../testing/asserts.ts";
|
||||
import { mkdtemp, mkdtempSync } from "./_fs_mkdtemp.ts";
|
||||
import { existsSync } from "./_fs_exists.ts";
|
||||
import { env } from "../process.ts";
|
||||
|
@ -16,56 +20,32 @@ const mkdtempP = promisify(mkdtemp);
|
|||
Deno.test({
|
||||
name: "[node/fs] mkdtemp",
|
||||
fn: async () => {
|
||||
try {
|
||||
const directory = await mkdtempP(prefix);
|
||||
assert(existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
} catch (error) {
|
||||
assert(false);
|
||||
}
|
||||
const directory = await mkdtempP(prefix);
|
||||
assert(existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[node/fs] mkdtemp (does not exists)",
|
||||
fn: async () => {
|
||||
try {
|
||||
const directory = await mkdtempP(doesNotExists);
|
||||
|
||||
// should have thrown already...
|
||||
assert(!existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
} catch (error) {
|
||||
assert(true);
|
||||
}
|
||||
await assertThrowsAsync(() => mkdtempP(doesNotExists));
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[node/fs] mkdtemp (with options)",
|
||||
fn: async () => {
|
||||
try {
|
||||
const directory = await mkdtempP(prefix, options);
|
||||
assert(existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
} catch (error) {
|
||||
assert(false);
|
||||
}
|
||||
const directory = await mkdtempP(prefix, options);
|
||||
assert(existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[node/fs] mkdtemp (with bad options)",
|
||||
fn: async () => {
|
||||
try {
|
||||
const directory = await mkdtempP(prefix, badOptions);
|
||||
|
||||
// should have thrown already...
|
||||
assert(!existsSync(directory));
|
||||
Deno.removeSync(directory);
|
||||
} catch (error) {
|
||||
assert(true);
|
||||
}
|
||||
await assertThrowsAsync(() => mkdtempP(prefix, badOptions));
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -82,16 +62,7 @@ Deno.test({
|
|||
Deno.test({
|
||||
name: "[node/fs] mkdtempSync (does not exists)",
|
||||
fn: () => {
|
||||
try {
|
||||
const directory = mkdtempSync(doesNotExists);
|
||||
// should have thrown already...
|
||||
|
||||
const dirExists = existsSync(directory);
|
||||
Deno.removeSync(directory);
|
||||
assert(!dirExists);
|
||||
} catch (error) {
|
||||
assert(true);
|
||||
}
|
||||
assertThrows(() => mkdtempSync(doesNotExists));
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -108,14 +79,6 @@ Deno.test({
|
|||
Deno.test({
|
||||
name: "[node/fs] mkdtempSync (with bad options)",
|
||||
fn: () => {
|
||||
try {
|
||||
const directory = mkdtempSync(prefix, badOptions);
|
||||
// should have thrown already...
|
||||
|
||||
Deno.removeSync(directory);
|
||||
assert(false);
|
||||
} catch (error) {
|
||||
assert(true);
|
||||
}
|
||||
assertThrows(() => mkdtempSync(prefix, badOptions));
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue