Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4510ca3

Browse filesBrowse files
shisamatargos
authored andcommitted
test: add tests for fs/promises chown functions
To increase test coverage for fs/promises, add tests for methods chown(), filehandle.chown() and lchown(). PR-URL: #20574 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
1 parent d91742a commit 4510ca3
Copy full SHA for 4510ca3

File tree

Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-0
lines changed
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.