1
0
Fork 0

Fix tests

This commit is contained in:
Chocobozzz 2016-03-07 18:53:03 +01:00
parent 6a1e67b30a
commit 3d446a26ad
11 changed files with 21 additions and 11 deletions

View file

@ -4,5 +4,5 @@ basePath=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
for i in $(seq 1 6); do
printf "use peertube-test%s;\ndb.dropDatabase();" "$i" | mongo
rm -rf "$basePath/../server/test$i"
rm -rf "$basePath/../test$i"
done

View file

@ -34,7 +34,7 @@
"dev": "concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"",
"livereload": "livereload ./client",
"start": "node server",
"test": "standard && mocha tests"
"test": "standard && mocha server/tests"
},
"dependencies": {
"async": "^1.2.1",
@ -73,6 +73,9 @@
"supertest": "^1.1.0"
},
"standard": {
"ignore": [
"client/"
],
"globals": [
"alert",
"confirm",

View file

@ -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)
}

View file

@ -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({

View file

@ -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 = {

View file

@ -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)
}

View file

@ -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,

View file

@ -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'))
// ---------------------------------------------------------------------------

View file

@ -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) {

View file

@ -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)

View file

@ -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