From 2ddee3e7cd845c842de42a0ffeb2113701b3ab8e Mon Sep 17 00:00:00 2001 From: jshkurti Date: Thu, 16 Apr 2015 21:08:30 +0200 Subject: [PATCH] added tests for NODE_PATH globalPaths init --- test/bash/env-refresh.sh | 11 +++++++++++ test/fixtures/local_require.js | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/fixtures/local_require.js diff --git a/test/bash/env-refresh.sh b/test/bash/env-refresh.sh index 76b23f6a..5479810a 100644 --- a/test/bash/env-refresh.sh +++ b/test/bash/env-refresh.sh @@ -52,3 +52,14 @@ $pm2 start env-ecosystem.json --env production sleep 0.5 grep "No worries!" out-env.log &> /dev/null spec "should use deploy.production.env.TEST_VARIABLE" + + +$pm2 kill +$pm2 l +NODE_PATH='/test' $pm2 start local_require.js +should 'should have loaded the right globalPaths' 'restart_time: 0' 1 + +$pm2 kill +$pm2 l +NODE_PATH='/test2' $pm2 start local_require.js -i 1 +should 'should have loaded the right globalPaths' 'restart_time: 0' 1 diff --git a/test/fixtures/local_require.js b/test/fixtures/local_require.js new file mode 100644 index 00000000..5c976af2 --- /dev/null +++ b/test/fixtures/local_require.js @@ -0,0 +1,18 @@ +var paths = require('module').globalPaths; + +if (Array.isArray(paths)) { + var found = false; + paths.forEach(function(elem) { + if (elem === process.env.NODE_PATH) { + found = true; + } + }); + + if (!found) + process.exit(1); + else + setInterval(function keepAlive() {}, 10000); +} +else { + process.exit(1); +}