Skip to content

Commit

Permalink
Skip the ncp / error / dest-permission test if running as root (#899)
Browse files Browse the repository at this point in the history
This test tries to create a directory where the current user does not have the
permissions to do so and expects a failure. However, the root user is by design
always allowed to do that (ignoring file permissions). So we must skip the test
in these cases then.

Fixes #898

Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
  • Loading branch information
dcermak and RyanZim committed May 7, 2021
1 parent fb6c0ca commit e6a9505
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/copy/__tests__/ncp/ncp-error-perm.test.js
Expand Up @@ -21,7 +21,9 @@ describe('ncp / error / dest-permission', () => {
const src = path.join(TEST_DIR, 'src')
const dest = path.join(TEST_DIR, 'dest')

if (os.platform().indexOf('win') === 0) return
// when we are root, then we will be able to create the subdirectory even if
// we don't have the permissions to do so, so no point in running this test
if (os.platform().indexOf('win') === 0 || os.userInfo().uid === 0) return

beforeEach(done => {
fse.emptyDir(TEST_DIR, err => {
Expand Down

0 comments on commit e6a9505

Please sign in to comment.