diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-10-30 18:34:37 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-10-30 18:34:37 +0100 |
commit | 77c2df95857b9fbc0a5935c51ffef073ffc277b7 (patch) | |
tree | b18cc8e1cb2c39915d6b4335f3d2b406d7b72892 | |
parent | e63dc45fa368de478ba3b37eabbfb1c233988348 (diff) | |
download | PeerTube-77c2df95857b9fbc0a5935c51ffef073ffc277b7.tar.gz PeerTube-77c2df95857b9fbc0a5935c51ffef073ffc277b7.tar.zst PeerTube-77c2df95857b9fbc0a5935c51ffef073ffc277b7.zip |
Fix tests
-rw-r--r-- | src/videos.js | 1 | ||||
-rw-r--r-- | src/webTorrentNode.js | 28 | ||||
-rw-r--r-- | test/api/multiplePods.js | 11 | ||||
-rw-r--r-- | test/api/singlePod.js | 2 |
4 files changed, 24 insertions, 18 deletions
diff --git a/src/videos.js b/src/videos.js index 605ce098f..48ec19d4d 100644 --- a/src/videos.js +++ b/src/videos.js | |||
@@ -103,6 +103,7 @@ | |||
103 | 103 | ||
104 | VideosDB.findById(id, function (err, video) { | 104 | VideosDB.findById(id, function (err, video) { |
105 | if (err || !video) { | 105 | if (err || !video) { |
106 | if (!err) err = new Error('Cannot find this video.') | ||
106 | logger.error('Cannot find this video.', { error: err }) | 107 | logger.error('Cannot find this video.', { error: err }) |
107 | return callback(err) | 108 | return callback(err) |
108 | } | 109 | } |
diff --git a/src/webTorrentNode.js b/src/webTorrentNode.js index 03bff7803..ebe8d5d81 100644 --- a/src/webTorrentNode.js +++ b/src/webTorrentNode.js | |||
@@ -8,16 +8,8 @@ | |||
8 | 8 | ||
9 | var logger = require('./logger') | 9 | var logger = require('./logger') |
10 | 10 | ||
11 | var host | 11 | var host = config.get('webserver.host') |
12 | var port | 12 | var port = config.get('webserver.port') |
13 | |||
14 | try { | ||
15 | host = config.get('webserver.host') | ||
16 | port = config.get('webserver.port') | ||
17 | } catch (e) { | ||
18 | host = 'client' | ||
19 | port = 1 | ||
20 | } | ||
21 | 13 | ||
22 | var nodeKey = 'webtorrentnode' + port | 14 | var nodeKey = 'webtorrentnode' + port |
23 | var processKey = 'webtorrent' + port | 15 | var processKey = 'webtorrent' + port |
@@ -33,7 +25,21 @@ | |||
33 | // Useful to kill it | 25 | // Useful to kill it |
34 | webtorrentnode.app = null | 26 | webtorrentnode.app = null |
35 | 27 | ||
36 | webtorrentnode.create = function (callback) { | 28 | webtorrentnode.create = function (options, callback) { |
29 | if (typeof options === 'function') { | ||
30 | callback = options | ||
31 | options = {} | ||
32 | } | ||
33 | |||
34 | // Override options | ||
35 | if (options.host) host = options.host | ||
36 | if (options.port) { | ||
37 | port = options.port | ||
38 | nodeKey = 'webtorrentnode' + port | ||
39 | processKey = 'webtorrent' + port | ||
40 | ipc.config.id = nodeKey | ||
41 | } | ||
42 | |||
37 | ipc.serve(function () { | 43 | ipc.serve(function () { |
38 | if (!webtorrentnode.silent) logger.info('IPC server ready.') | 44 | if (!webtorrentnode.silent) logger.info('IPC server ready.') |
39 | 45 | ||
diff --git a/test/api/multiplePods.js b/test/api/multiplePods.js index fff179006..81d4b06b6 100644 --- a/test/api/multiplePods.js +++ b/test/api/multiplePods.js | |||
@@ -61,7 +61,7 @@ | |||
61 | .end(function (err, res) { | 61 | .end(function (err, res) { |
62 | if (err) throw err | 62 | if (err) throw err |
63 | 63 | ||
64 | webtorrent.create(function () { | 64 | webtorrent.create({ host: 'client', port: '1' }, function () { |
65 | done() | 65 | done() |
66 | }) | 66 | }) |
67 | }) | 67 | }) |
@@ -214,7 +214,7 @@ | |||
214 | describe('Should seed the uploaded video', function () { | 214 | describe('Should seed the uploaded video', function () { |
215 | it('Should add the file 1 by asking pod 3', function (done) { | 215 | it('Should add the file 1 by asking pod 3', function (done) { |
216 | // Yes, this could be long | 216 | // Yes, this could be long |
217 | this.timeout(60000) | 217 | this.timeout(200000) |
218 | 218 | ||
219 | getVideosList(urls[2], function (err, res) { | 219 | getVideosList(urls[2], function (err, res) { |
220 | if (err) throw err | 220 | if (err) throw err |
@@ -232,15 +232,13 @@ | |||
232 | 232 | ||
233 | it('Should add the file 2 by asking pod 1', function (done) { | 233 | it('Should add the file 2 by asking pod 1', function (done) { |
234 | // Yes, this could be long | 234 | // Yes, this could be long |
235 | this.timeout(60000) | 235 | this.timeout(200000) |
236 | 236 | ||
237 | getVideosList(urls[0], function (err, res) { | 237 | getVideosList(urls[0], function (err, res) { |
238 | if (err) throw err | 238 | if (err) throw err |
239 | 239 | ||
240 | var video = res.body[1] | 240 | var video = res.body[1] |
241 | 241 | ||
242 | video_id = video._id | ||
243 | |||
244 | webtorrent.add(video.magnetUri, function (torrent) { | 242 | webtorrent.add(video.magnetUri, function (torrent) { |
245 | expect(torrent.files).to.exist | 243 | expect(torrent.files).to.exist |
246 | expect(torrent.files.length).to.equal(1) | 244 | expect(torrent.files.length).to.equal(1) |
@@ -253,12 +251,13 @@ | |||
253 | 251 | ||
254 | it('Should add the file 3 by asking pod 2', function (done) { | 252 | it('Should add the file 3 by asking pod 2', function (done) { |
255 | // Yes, this could be long | 253 | // Yes, this could be long |
256 | this.timeout(60000) | 254 | this.timeout(200000) |
257 | 255 | ||
258 | getVideosList(urls[1], function (err, res) { | 256 | getVideosList(urls[1], function (err, res) { |
259 | if (err) throw err | 257 | if (err) throw err |
260 | 258 | ||
261 | var video = res.body[2] | 259 | var video = res.body[2] |
260 | video_id = res.body[1]._id | ||
262 | 261 | ||
263 | webtorrent.add(video.magnetUri, function (torrent) { | 262 | webtorrent.add(video.magnetUri, function (torrent) { |
264 | expect(torrent.files).to.exist | 263 | expect(torrent.files).to.exist |
diff --git a/test/api/singlePod.js b/test/api/singlePod.js index 59a617970..149c10b9e 100644 --- a/test/api/singlePod.js +++ b/test/api/singlePod.js | |||
@@ -23,7 +23,7 @@ | |||
23 | app = app1 | 23 | app = app1 |
24 | url = url1 | 24 | url = url1 |
25 | 25 | ||
26 | webtorrent.create(function () { | 26 | webtorrent.create({ host: 'client', port: '1' }, function () { |
27 | done() | 27 | done() |
28 | }) | 28 | }) |
29 | }) | 29 | }) |