Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/tap/correct-mkdir.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/tap/correct-mkdir.js b/test/tap/correct-mkdir.js
index 7405041a6..a4f865987 100644
--- a/test/tap/correct-mkdir.js
+++ b/test/tap/correct-mkdir.js
@@ -57,6 +57,37 @@ test('correct-mkdir: no race conditions', function (t) {
correctMkdir(cache_dir, handleCallFinish)
})
+test('correct-mkdir: ignore ENOENTs from chownr', function (t) {
+ var mock_fs = {}
+ mock_fs.stat = function (path, cb) {
+ if (path === cache_dir) {
+ cb(null, {
+ isDirectory: function () {
+ return true
+ }
+ })
+ } else {
+ assert.ok(false, 'Unhandled stat path: ' + path)
+ }
+ }
+ var mock_chownr = function (path, uid, gid, cb) {
+ cb({code: 'ENOENT'})
+ }
+ var mocks = {
+ 'graceful-fs': mock_fs,
+ 'chownr': mock_chownr
+ }
+ var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
+
+ function handleCallFinish (err) {
+ t.ifErr(err, 'chownr\'s ENOENT errors were ignored')
+ t.end()
+ }
+ correctMkdir(cache_dir, handleCallFinish)
+})
+
+// NEED TO RUN LAST
+
// These test checks that Windows users are protected by crashes related to
// unexpectedly having a UID/GID other than 0 if a user happens to add these
// variables to their environment. There are assumptions in correct-mkdir