mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
74e0ca3f49
PR-URL: https://github.com/nodejs/node/pull/49125 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
36 lines
960 B
JavaScript
36 lines
960 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
const { access, copyFile, open } = require('fs').promises;
|
|
|
|
async function validate() {
|
|
tmpdir.refresh();
|
|
const dest = tmpdir.resolve('baz.js');
|
|
await assert.rejects(
|
|
copyFile(fixtures.path('baz.js'), dest, 'r'),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
}
|
|
);
|
|
await copyFile(fixtures.path('baz.js'), dest);
|
|
await assert.rejects(
|
|
access(dest, 'r'),
|
|
{ code: 'ERR_INVALID_ARG_TYPE', message: /mode/ }
|
|
);
|
|
await access(dest);
|
|
const handle = await open(dest, 'r+');
|
|
await handle.datasync();
|
|
await handle.sync();
|
|
const buf = Buffer.from('hello world');
|
|
await handle.write(buf);
|
|
const ret = await handle.read(Buffer.alloc(11), 0, 11, 0);
|
|
assert.strictEqual(ret.bytesRead, 11);
|
|
assert.deepStrictEqual(ret.buffer, buf);
|
|
await handle.close();
|
|
}
|
|
|
|
validate();
|