diff options
Diffstat (limited to 'cli/tests/unit_node/_fs/_fs_fstat_test.ts')
-rw-r--r-- | cli/tests/unit_node/_fs/_fs_fstat_test.ts | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_fstat_test.ts b/cli/tests/unit_node/_fs/_fs_fstat_test.ts index a2c2ae00e..963f79abc 100644 --- a/cli/tests/unit_node/_fs/_fs_fstat_test.ts +++ b/cli/tests/unit_node/_fs/_fs_fstat_test.ts @@ -7,24 +7,23 @@ import type { BigIntStats, Stats } from "node:fs"; Deno.test({ name: "ASYNC: get a file Stats", async fn() { - const file = await Deno.makeTempFile(); - const { rid } = await Deno.open(file); + const filePath = await Deno.makeTempFile(); + using file = await Deno.open(filePath); await new Promise<Stats>((resolve, reject) => { - fstat(rid, (err: Error | null, stat: Stats) => { + fstat(file.rid, (err: Error | null, stat: Stats) => { if (err) reject(err); resolve(stat); }); }) .then( (stat) => { - assertStats(stat, Deno.fstatSync(rid)); + assertStats(stat, Deno.fstatSync(file.rid)); }, () => fail(), ) .finally(() => { - Deno.removeSync(file); - Deno.close(rid); + Deno.removeSync(filePath); }); }, }); @@ -32,22 +31,25 @@ Deno.test({ Deno.test({ name: "ASYNC: get a file BigInt Stats", async fn() { - const file = await Deno.makeTempFile(); - const { rid } = await Deno.open(file); + const filePath = await Deno.makeTempFile(); + using file = await Deno.open(filePath); await new Promise<BigIntStats>((resolve, reject) => { - fstat(rid, { bigint: true }, (err: Error | null, stat: BigIntStats) => { - if (err) reject(err); - resolve(stat); - }); + fstat( + file.rid, + { bigint: true }, + (err: Error | null, stat: BigIntStats) => { + if (err) reject(err); + resolve(stat); + }, + ); }) .then( - (stat) => assertStatsBigInt(stat, Deno.fstatSync(rid)), + (stat) => assertStatsBigInt(stat, Deno.fstatSync(file.rid)), () => fail(), ) .finally(() => { - Deno.removeSync(file); - Deno.close(rid); + Deno.removeSync(filePath); }); }, }); @@ -55,14 +57,13 @@ Deno.test({ Deno.test({ name: "SYNC: get a file Stats", fn() { - const file = Deno.makeTempFileSync(); - const { rid } = Deno.openSync(file); + const filePath = Deno.makeTempFileSync(); + using file = Deno.openSync(filePath); try { - assertStats(fstatSync(rid), Deno.fstatSync(rid)); + assertStats(fstatSync(file.rid), Deno.fstatSync(file.rid)); } finally { - Deno.removeSync(file); - Deno.close(rid); + Deno.removeSync(filePath); } }, }); @@ -70,14 +71,16 @@ Deno.test({ Deno.test({ name: "SYNC: get a file BigInt Stats", fn() { - const file = Deno.makeTempFileSync(); - const { rid } = Deno.openSync(file); + const filePath = Deno.makeTempFileSync(); + using file = Deno.openSync(filePath); try { - assertStatsBigInt(fstatSync(rid, { bigint: true }), Deno.fstatSync(rid)); + assertStatsBigInt( + fstatSync(file.rid, { bigint: true }), + Deno.fstatSync(file.rid), + ); } finally { - Deno.removeSync(file); - Deno.close(rid); + Deno.removeSync(filePath); } }, }); |