GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add filehandle sync() and datasync() tests · nodejs/node@678313d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-fs-promises-file-handle-sync.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-fs-promises-file-handle-sync.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const fixtures = require('../common/fixtures');
5+
const tmpdir = require('../common/tmpdir');
6+
7+
const { access, copyFile, open } = require('fs').promises;
8+
const path = require('path');
9+
10+
common.crashOnUnhandledRejection();
11+
12+
async function validateSync() {
13+
tmpdir.refresh();
14+
const dest = path.resolve(tmpdir.path, 'baz.js');
15+
await copyFile(fixtures.path('baz.js'), dest);
16+
await access(dest, 'r');
17+
const handle = await open(dest, 'r+');
18+
await handle.datasync();
19+
await handle.sync();
20+
const buf = Buffer.from('hello world');
21+
await handle.write(buf);
22+
const ret = await handle.read(Buffer.alloc(11), 0, 11, 0);
23+
assert.strictEqual(ret.bytesRead, 11);
24+
assert.deepStrictEqual(ret.buffer, buf);
25+
}
26+
27+
validateSync();

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.