]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - src/utils.js
Create a constants module to easily modify some constants in a test
[github/Chocobozzz/PeerTube.git] / src / utils.js
index 30edcd0e9db5601a46f72166142e7f196f75a1f3..5880c6c90409e08ff67febde7fbbe9a22e82d41a 100644 (file)
@@ -10,6 +10,7 @@
   var replay = require('request-replay')
   var ursa = require('ursa')
 
+  var constants = require('./constants')
   var logger = require('./logger')
 
   var utils = {}
     }
 
     logger.debug('Make retry requests to %s.', to_pod.url)
-    // Default 10 but in tests we want to be faster
-    var retries = utils.isTestInstance() ? 2 : 10
 
     replay(
       request.post(params, function (err, response, body) {
         callbackEach(err, response, body, params.url, to_pod)
       }),
       {
-        retries: retries,
+        retries: constants.REQUEST_RETRIES,
         factor: 3,
         maxTimeout: Infinity,
         errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ]
     process.kill(-webtorrent_process.pid)
   }
 
-  utils.isTestInstance = function () {
-    return (process.env.NODE_ENV === 'test')
-  }
-
   module.exports = utils
 })()