Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add tests for fs/promises chown to increase coverage
To increase test coverage for fs/promises, add tests for
methods chown(), filehandle.chown() and lchown().
  • Loading branch information
shisama authored and TimothyGu committed Jul 30, 2018
commit 7521a3e06f3d159849ce9b9848f0a6058d2ce82b
9 changes: 9 additions & 0 deletions test/parallel/test-fs-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const fsPromises = fs.promises;
const {
access,
chmod,
chown,
copyFile,
lchown,
link,
lchmod,
lstat,
Expand Down Expand Up @@ -107,6 +109,9 @@ function verifyStatObject(stat) {
await chmod(dest, (0o10777));
await handle.chmod(0o10777);

await chown(dest, process.getuid(), process.getgid());
await handle.chown(process.getuid(), process.getgid());

await utimes(dest, new Date(), new Date());

try {
Expand All @@ -130,6 +135,10 @@ function verifyStatObject(stat) {
if (common.canCreateSymLink()) {
const newLink = path.resolve(tmpDir, 'baz3.js');
await symlink(newPath, newLink);
if (common.isOSX) {
// lchown is only available on macOS
await lchown(newLink, process.getuid(), process.getgid());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #21498 lands, this could become !common.isWindows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig PTAL Thanks.

}
stats = await lstat(newLink);
verifyStatObject(stats);

Expand Down