-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test: add fs/promises filehandle sync() and datasync() tests. #20530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
05d5a1b
4c72ba1
c431fc5
d462d2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
To increase test coverage for fs/promises, added tests for filehandle.sync and filehandle.datasync.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const fixtures = require('../common/fixtures'); | ||
| const tmpdir = require('../common/tmpdir'); | ||
|
|
||
| const { access, copyFile, open, read, write } = require('fs/promises'); | ||
| const path = require('path'); | ||
|
|
||
| common.crashOnUnhandledRejection(); | ||
|
|
||
| async function validateSync() { | ||
| tmpdir.refresh(); | ||
| const dest = path.resolve(tmpdir.path, 'baz.js'); | ||
| await copyFile(fixtures.path('baz.js'), dest); | ||
| await access(dest, 'r'); | ||
| const handle = await open(dest, 'r+'); | ||
| await handle.datasync(); | ||
| await handle.sync(); | ||
| const buf = Buffer.from('hello world'); | ||
| await write(handle, buf); | ||
| const ret = await read(handle, Buffer.alloc(11), 0, 11, 0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ChALkeR Fixed them. Thanks. |
||
| assert.strictEqual(ret.bytesRead, 11); | ||
| assert.deepStrictEqual(ret.buffer, buf); | ||
| } | ||
|
|
||
| validateSync().then(common.mustCall()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @joyeecheung Thanks. Removed |
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle.write(buf)?Same results and coverage, also see #20559.