From 6b3be01a00d9eaa134a5e58570239d6c1cd3bf54 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 22 Jun 2020 20:58:52 +0800 Subject: feat(unstable): add Deno.fstatSync and fstat (#6425) --- cli/tests/unit/stat_test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/stat_test.ts b/cli/tests/unit/stat_test.ts index 67598a2d7..b32949286 100644 --- a/cli/tests/unit/stat_test.ts +++ b/cli/tests/unit/stat_test.ts @@ -6,6 +6,36 @@ import { pathToAbsoluteFileUrl, } from "./test_util.ts"; +unitTest({ perms: { read: true } }, function fstatSyncSuccess(): void { + const file = Deno.openSync("README.md"); + const fileInfo = Deno.fstatSync(file.rid); + assert(fileInfo.isFile); + assert(!fileInfo.isSymlink); + assert(!fileInfo.isDirectory); + assert(fileInfo.size); + assert(fileInfo.atime); + assert(fileInfo.mtime); + assert(fileInfo.birthtime); + + Deno.close(file.rid); +}); + +unitTest({ perms: { read: true } }, async function fstatSuccess(): Promise< + void +> { + const file = await Deno.open("README.md"); + const fileInfo = await Deno.fstat(file.rid); + assert(fileInfo.isFile); + assert(!fileInfo.isSymlink); + assert(!fileInfo.isDirectory); + assert(fileInfo.size); + assert(fileInfo.atime); + assert(fileInfo.mtime); + assert(fileInfo.birthtime); + + Deno.close(file.rid); +}); + unitTest( { perms: { read: true, write: true } }, function statSyncSuccess(): void { -- cgit v1.2.3