summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/stat_test.ts8
-rw-r--r--cli/tests/unit/sync_test.ts13
-rw-r--r--cli/tests/unit/truncate_test.ts6
3 files changed, 8 insertions, 19 deletions
diff --git a/cli/tests/unit/stat_test.ts b/cli/tests/unit/stat_test.ts
index cbc5909b5..ccb17b164 100644
--- a/cli/tests/unit/stat_test.ts
+++ b/cli/tests/unit/stat_test.ts
@@ -8,7 +8,7 @@ import {
} from "./test_util.ts";
Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() {
- const file = Deno.openSync("README.md");
+ using file = Deno.openSync("README.md");
const fileInfo = Deno.fstatSync(file.rid);
assert(fileInfo.isFile);
assert(!fileInfo.isSymlink);
@@ -18,12 +18,10 @@ Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() {
assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux");
-
- Deno.close(file.rid);
});
Deno.test({ permissions: { read: true } }, async function fstatSuccess() {
- const file = await Deno.open("README.md");
+ using file = await Deno.open("README.md");
const fileInfo = await Deno.fstat(file.rid);
assert(fileInfo.isFile);
assert(!fileInfo.isSymlink);
@@ -33,8 +31,6 @@ Deno.test({ permissions: { read: true } }, async function fstatSuccess() {
assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux");
-
- Deno.close(file.rid);
});
Deno.test(
diff --git a/cli/tests/unit/sync_test.ts b/cli/tests/unit/sync_test.ts
index 97624d270..c6da9f23f 100644
--- a/cli/tests/unit/sync_test.ts
+++ b/cli/tests/unit/sync_test.ts
@@ -5,7 +5,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
function fdatasyncSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
- const file = Deno.openSync(filename, {
+ using file = Deno.openSync(filename, {
read: true,
write: true,
create: true,
@@ -13,8 +13,6 @@ Deno.test(
const data = new Uint8Array(64);
Deno.writeSync(file.rid, data);
Deno.fdatasyncSync(file.rid);
- assertEquals(Deno.readFileSync(filename), data);
- Deno.close(file.rid);
Deno.removeSync(filename);
},
);
@@ -23,7 +21,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
async function fdatasyncSuccess() {
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
- const file = await Deno.open(filename, {
+ using file = await Deno.open(filename, {
read: true,
write: true,
create: true,
@@ -32,7 +30,6 @@ Deno.test(
await Deno.write(file.rid, data);
await Deno.fdatasync(file.rid);
assertEquals(await Deno.readFile(filename), data);
- Deno.close(file.rid);
await Deno.remove(filename);
},
);
@@ -41,7 +38,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
function fsyncSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
- const file = Deno.openSync(filename, {
+ using file = Deno.openSync(filename, {
read: true,
write: true,
create: true,
@@ -50,7 +47,6 @@ Deno.test(
file.truncateSync(size);
Deno.fsyncSync(file.rid);
assertEquals(Deno.statSync(filename).size, size);
- Deno.close(file.rid);
Deno.removeSync(filename);
},
);
@@ -59,7 +55,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
async function fsyncSuccess() {
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
- const file = await Deno.open(filename, {
+ using file = await Deno.open(filename, {
read: true,
write: true,
create: true,
@@ -68,7 +64,6 @@ Deno.test(
await file.truncate(size);
await Deno.fsync(file.rid);
assertEquals((await Deno.stat(filename)).size, size);
- Deno.close(file.rid);
await Deno.remove(filename);
},
);
diff --git a/cli/tests/unit/truncate_test.ts b/cli/tests/unit/truncate_test.ts
index 97d4db62d..95b76052d 100644
--- a/cli/tests/unit/truncate_test.ts
+++ b/cli/tests/unit/truncate_test.ts
@@ -5,7 +5,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
function ftruncateSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_ftruncateSync.txt";
- const file = Deno.openSync(filename, {
+ using file = Deno.openSync(filename, {
create: true,
read: true,
write: true,
@@ -18,7 +18,6 @@ Deno.test(
file.truncateSync(-5);
assertEquals(Deno.readFileSync(filename).byteLength, 0);
- Deno.close(file.rid);
Deno.removeSync(filename);
},
);
@@ -27,7 +26,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
async function ftruncateSuccess() {
const filename = Deno.makeTempDirSync() + "/test_ftruncate.txt";
- const file = await Deno.open(filename, {
+ using file = await Deno.open(filename, {
create: true,
read: true,
write: true,
@@ -40,7 +39,6 @@ Deno.test(
await file.truncate(-5);
assertEquals((await Deno.readFile(filename)).byteLength, 0);
- Deno.close(file.rid);
await Deno.remove(filename);
},
);