1
0
Fork 0

Fix tests

This commit is contained in:
Chocobozzz 2015-10-30 18:34:37 +01:00
parent e63dc45fa3
commit 77c2df9585
4 changed files with 24 additions and 18 deletions

View file

@ -103,6 +103,7 @@
VideosDB.findById(id, function (err, video) {
if (err || !video) {
if (!err) err = new Error('Cannot find this video.')
logger.error('Cannot find this video.', { error: err })
return callback(err)
}

View file

@ -8,16 +8,8 @@
var logger = require('./logger')
var host
var port
try {
host = config.get('webserver.host')
port = config.get('webserver.port')
} catch (e) {
host = 'client'
port = 1
}
var host = config.get('webserver.host')
var port = config.get('webserver.port')
var nodeKey = 'webtorrentnode' + port
var processKey = 'webtorrent' + port
@ -33,7 +25,21 @@
// Useful to kill it
webtorrentnode.app = null
webtorrentnode.create = function (callback) {
webtorrentnode.create = function (options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
// Override options
if (options.host) host = options.host
if (options.port) {
port = options.port
nodeKey = 'webtorrentnode' + port
processKey = 'webtorrent' + port
ipc.config.id = nodeKey
}
ipc.serve(function () {
if (!webtorrentnode.silent) logger.info('IPC server ready.')

View file

@ -61,7 +61,7 @@
.end(function (err, res) {
if (err) throw err
webtorrent.create(function () {
webtorrent.create({ host: 'client', port: '1' }, function () {
done()
})
})
@ -214,7 +214,7 @@
describe('Should seed the uploaded video', function () {
it('Should add the file 1 by asking pod 3', function (done) {
// Yes, this could be long
this.timeout(60000)
this.timeout(200000)
getVideosList(urls[2], function (err, res) {
if (err) throw err
@ -232,15 +232,13 @@
it('Should add the file 2 by asking pod 1', function (done) {
// Yes, this could be long
this.timeout(60000)
this.timeout(200000)
getVideosList(urls[0], function (err, res) {
if (err) throw err
var video = res.body[1]
video_id = video._id
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist
expect(torrent.files.length).to.equal(1)
@ -253,12 +251,13 @@
it('Should add the file 3 by asking pod 2', function (done) {
// Yes, this could be long
this.timeout(60000)
this.timeout(200000)
getVideosList(urls[1], function (err, res) {
if (err) throw err
var video = res.body[2]
video_id = res.body[1]._id
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist

View file

@ -23,7 +23,7 @@
app = app1
url = url1
webtorrent.create(function () {
webtorrent.create({ host: 'client', port: '1' }, function () {
done()
})
})