Skip to content

Commit 6ccc2e3

Browse files
committed
Use better ways to stat in test
1 parent fbd1638 commit 6ccc2e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/zip.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { configureSingle, fs } from '@zenfs/core';
33
// @ts-expect-error 7016
44
import { setupLogs } from '@zenfs/core/tests/logs.js';
55
import assert from 'node:assert/strict';
6-
import { openSync, readFileSync, readSync, statSync } from 'node:fs';
6+
import { fstatSync, openSync, readFileSync, readSync } from 'node:fs';
77
import { open } from 'node:fs/promises';
88
import { suite, test } from 'node:test';
99

@@ -41,10 +41,12 @@ suite('Basic ZIP operations', () => {
4141
_runTests();
4242
});
4343

44-
suite('ZIP Streaming', () => {
44+
suite('ZIP Streaming', async () => {
45+
await using handle = await open(import.meta.dirname + '/files/data.zip');
46+
4547
test('Configure', async () => {
46-
const stream = (await open(import.meta.dirname + '/files/data.zip')).readableWebStream() as ReadableStream;
47-
const { size } = statSync(import.meta.dirname + '/files/data.zip');
48+
const stream = handle.readableWebStream() as ReadableStream;
49+
const { size } = await handle.stat();
4850
await configureSingle({ backend: Zip, data: fromStream(stream, size) });
4951
});
5052

@@ -54,7 +56,7 @@ suite('ZIP Streaming', () => {
5456
suite('Custom data source', () => {
5557
test('Configure', async () => {
5658
const fd = openSync(import.meta.dirname + '/files/data.zip', 'r');
57-
const { size } = statSync(import.meta.dirname + '/files/data.zip');
59+
const { size } = fstatSync(fd);
5860

5961
await configureSingle({
6062
backend: Zip,

0 commit comments

Comments
 (0)