From 3d446a26ada901331faaaf3be9083dfe6773b50a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 7 Mar 2016 18:53:03 +0100 Subject: Fix tests --- server/controllers/api/v1/index.js | 7 +++++++ server/helpers/logger.js | 2 +- server/helpers/peertubeCrypto.js | 2 +- server/initializers/checker.js | 2 +- server/lib/videos.js | 2 +- server/models/videos.js | 2 +- server/tests/api/checkParams.js | 2 +- server/tests/api/singlePod.js | 2 +- server/tests/api/utils.js | 4 ++-- 9 files changed, 16 insertions(+), 9 deletions(-) (limited to 'server') diff --git a/server/controllers/api/v1/index.js b/server/controllers/api/v1/index.js index 07a68ed9d..abbc5eb60 100644 --- a/server/controllers/api/v1/index.js +++ b/server/controllers/api/v1/index.js @@ -11,7 +11,14 @@ var videosController = require('./videos') router.use('/pods', podsController) router.use('/remotevideos', remoteVideosController) router.use('/videos', videosController) +router.use('/*', badRequest) // --------------------------------------------------------------------------- module.exports = router + +// --------------------------------------------------------------------------- + +function badRequest (req, res, next) { + res.sendStatus(400) +} diff --git a/server/helpers/logger.js b/server/helpers/logger.js index 67f69a875..1c15a0edd 100644 --- a/server/helpers/logger.js +++ b/server/helpers/logger.js @@ -6,7 +6,7 @@ var path = require('path') var winston = require('winston') winston.emitErrs = true -var logDir = path.join(__dirname, '..', config.get('storage.logs')) +var logDir = path.join(__dirname, '..', '..', config.get('storage.logs')) var logger = new winston.Logger({ transports: [ new winston.transports.File({ diff --git a/server/helpers/peertubeCrypto.js b/server/helpers/peertubeCrypto.js index 29b9d79c9..7e65c43e1 100644 --- a/server/helpers/peertubeCrypto.js +++ b/server/helpers/peertubeCrypto.js @@ -9,7 +9,7 @@ var ursa = require('ursa') var logger = require('./logger') -var certDir = path.join(__dirname, '..', config.get('storage.certs')) +var certDir = path.join(__dirname, '..', '..', config.get('storage.certs')) var algorithm = 'aes-256-ctr' var peertubeCrypto = { diff --git a/server/initializers/checker.js b/server/initializers/checker.js index ec7bc0ad2..44d9ea85b 100644 --- a/server/initializers/checker.js +++ b/server/initializers/checker.js @@ -34,7 +34,7 @@ function createDirectoriesIfNotExist () { for (var key of Object.keys(storages)) { var dir = storages[key] try { - mkdirp.sync(path.join(__dirname, '..', dir)) + mkdirp.sync(path.join(__dirname, '..', '..', dir)) } catch (error) { throw new Error('Cannot create ' + path + ':' + error) } diff --git a/server/lib/videos.js b/server/lib/videos.js index 1e0a83b8b..3c6ee4a65 100644 --- a/server/lib/videos.js +++ b/server/lib/videos.js @@ -9,7 +9,7 @@ var webtorrent = require('../lib/webtorrent') var logger = require('../helpers/logger') var Videos = require('../models/videos') -var uploadDir = path.join(__dirname, '..', config.get('storage.uploads')) +var uploadDir = path.join(__dirname, '..', '..', config.get('storage.uploads')) var videos = { seed: seed, diff --git a/server/models/videos.js b/server/models/videos.js index 5e2eeae07..436c08bfd 100644 --- a/server/models/videos.js +++ b/server/models/videos.js @@ -12,7 +12,7 @@ var logger = require('../helpers/logger') var http = config.get('webserver.https') === true ? 'https' : 'http' var host = config.get('webserver.host') var port = config.get('webserver.port') -var uploadDir = path.join(__dirname, '..', config.get('storage.uploads')) +var uploadDir = path.join(__dirname, '..', '..', config.get('storage.uploads')) // --------------------------------------------------------------------------- diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js index 1c1ec71b3..01b620873 100644 --- a/server/tests/api/checkParams.js +++ b/server/tests/api/checkParams.js @@ -252,7 +252,7 @@ describe('Test parameters validator', function () { it('Should have 404 with nothing', function (done) { request(url) .delete(path) - .expect(404, done) + .expect(400, done) }) it('Should fail without a mongodb id', function (done) { diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index 3dd72c01b..d572aacf6 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js @@ -112,7 +112,7 @@ describe('Test a single pod', function () { utils.removeVideo(url, video_id, function (err) { if (err) throw err - fs.readdir(pathUtils.join(__dirname, '../../test1/uploads/'), function (err, files) { + fs.readdir(pathUtils.join(__dirname, '../../../test1/uploads/'), function (err, files) { if (err) throw err expect(files.length).to.equal(0) diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js index 47b706294..c70696571 100644 --- a/server/tests/api/utils.js +++ b/server/tests/api/utils.js @@ -22,7 +22,7 @@ var testUtils = { // ---------------------- Export functions -------------------- function flushTests (callback) { - exec(pathUtils.join(__dirname, '../../scripts/clean_test.sh'), callback) + exec(pathUtils.join(__dirname, '../../../bin/clean_test.sh'), callback) } function getFriendsList (url, end) { @@ -139,7 +139,7 @@ function runServer (number, callback) { detached: true } - var app = fork(pathUtils.join(__dirname, '../../server.js'), [], options) + var app = fork(pathUtils.join(__dirname, '../../../server.js'), [], options) app.stdout.on('data', function onStdout (data) { var dont_continue = false // Check if all required sentences are here -- cgit v1.2.3