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 tests for fs/promises chown functions · nodejs/node@4510ca3

File tree

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

‎test/parallel/test-fs-promises.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises.js
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const fsPromises = fs.promises;
1010
const {
1111
access,
1212
chmod,
13+
chown,
1314
copyFile,
15+
lchown,
1416
link,
1517
lchmod,
1618
lstat,
@@ -107,6 +109,33 @@ function verifyStatObject(stat) {
107109
await chmod(dest, (0o10777));
108110
await handle.chmod(0o10777);
109111

112+
if (!common.isWindows) {
113+
await chown(dest, process.getuid(), process.getgid());
114+
await handle.chown(process.getuid(), process.getgid());
115+
}
116+
117+
assert.rejects(
118+
async () => {
119+
await chown(dest, 1, -1);
120+
},
121+
{
122+
code: 'ERR_OUT_OF_RANGE',
123+
name: 'RangeError [ERR_OUT_OF_RANGE]',
124+
message: 'The value of "gid" is out of range. ' +
125+
'It must be >= 0 && < 4294967296. Received -1'
126+
});
127+
128+
assert.rejects(
129+
async () => {
130+
await handle.chown(1, -1);
131+
},
132+
{
133+
code: 'ERR_OUT_OF_RANGE',
134+
name: 'RangeError [ERR_OUT_OF_RANGE]',
135+
message: 'The value of "gid" is out of range. ' +
136+
'It must be >= 0 && < 4294967296. Received -1'
137+
});
138+
110139
await utimes(dest, new Date(), new Date());
111140

112141
try {
@@ -130,6 +159,9 @@ function verifyStatObject(stat) {
130159
if (common.canCreateSymLink()) {
131160
const newLink = path.resolve(tmpDir, 'baz3.js');
132161
await symlink(newPath, newLink);
162+
if (!common.isWindows) {
163+
await lchown(newLink, process.getuid(), process.getgid());
164+
}
133165
stats = await lstat(newLink);
134166
verifyStatObject(stats);
135167

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.