mirror of
https://github.com/denoland/deno
synced 2024-10-04 07:09:20 +00:00
tests: deflake _fs_read_test.ts again (#19705)
This commit is contained in:
parent
ae657731f7
commit
aaabff710f
|
@ -132,11 +132,12 @@ Deno.test({
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[std/node/fs] Read fs.read(fd, options, cb) signature",
|
name: "[std/node/fs] Read fs.read(fd, options, cb) signature",
|
||||||
async fn() {
|
async fn() {
|
||||||
|
const promise = deferred();
|
||||||
const file = Deno.makeTempFileSync();
|
const file = Deno.makeTempFileSync();
|
||||||
Deno.writeTextFileSync(file, "hi there");
|
Deno.writeTextFileSync(file, "hi there");
|
||||||
const fd = openSync(file, "r+");
|
const fd = openSync(file, "r+");
|
||||||
const buf = Buffer.alloc(11);
|
const buf = Buffer.alloc(11);
|
||||||
await read(
|
read(
|
||||||
fd,
|
fd,
|
||||||
{
|
{
|
||||||
buffer: buf,
|
buffer: buf,
|
||||||
|
@ -145,15 +146,22 @@ Deno.test({
|
||||||
position: null,
|
position: null,
|
||||||
},
|
},
|
||||||
(err, bytesRead, data) => {
|
(err, bytesRead, data) => {
|
||||||
assertEquals(err, null);
|
try {
|
||||||
assertStrictEquals(bytesRead, 8);
|
assertEquals(err, null);
|
||||||
assertEquals(
|
assertStrictEquals(bytesRead, 8);
|
||||||
data,
|
assertEquals(
|
||||||
Buffer.from([104, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]),
|
data,
|
||||||
);
|
Buffer.from([104, 105, 32, 116, 104, 101, 114, 101, 0, 0, 0]),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
promise.reject(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
promise.resolve();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
closeSync(fd);
|
closeSync(fd);
|
||||||
|
await promise;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue