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:
authorKat Marchán <kzm@sykosomatic.org>2016-06-25 04:50:03 +0300
committerKat Marchán <kzm@sykosomatic.org>2016-07-01 01:50:09 +0300
commit69267f4fbd1467ce576f173909ced361f8fe2a9d (patch)
treebe781579cb295d69fed872d9ac912517e856ba0a
parente5f50ea9f84fe8cac6978d18f7efdf43834928e7 (diff)
test: Added tests to verify correct-mkdir race patch
PR-URL: https://github.com/npm/npm/pull/13023 Credit: @zkat Reviewed-By: @othiym23
-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