describe('Test multiple pods', function () {
let servers = []
- const to_remove = []
+ const toRemove = []
before(function (done) {
this.timeout(30000)
async.series([
// Run servers
function (next) {
- utils.flushAndRunMultipleServers(3, function (servers_run) {
- servers = servers_run
+ utils.flushAndRunMultipleServers(3, function (serversRun) {
+ servers = serversRun
next()
})
},
// Get the access tokens
function (next) {
- async.each(servers, function (server, callback_each) {
- utils.loginAndGetAccessToken(server, function (err, access_token) {
- if (err) return callback_each(err)
+ async.each(servers, function (server, callbackEach) {
+ utils.loginAndGetAccessToken(server, function (err, accessToken) {
+ if (err) return callbackEach(err)
- server.access_token = access_token
- callback_each()
+ server.accessToken = accessToken
+ callbackEach()
})
}, next)
},
if (err) throw err
async.each(servers, function (server, callback) {
- let base_magnet = null
+ let baseMagnet = null
utils.getVideosList(server.url, function (err, res) {
if (err) throw err
expect(video.description).to.equal('my super description for pod 1')
expect(video.podUrl).to.equal('http://localhost:9001')
expect(video.magnetUri).to.exist
+ expect(video.duration).to.equal(10)
if (server.url !== 'http://localhost:9001') {
expect(video.isLocal).to.be.false
}
// All pods should have the same magnet Uri
- if (base_magnet === null) {
- base_magnet = video.magnetUri
+ if (baseMagnet === null) {
+ baseMagnet = video.magnetUri
} else {
expect(video.magnetUri).to.equal.magnetUri
}
- callback()
+ utils.testImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ callback()
+ })
})
}, done)
}
if (err) throw err
async.each(servers, function (server, callback) {
- let base_magnet = null
+ let baseMagnet = null
utils.getVideosList(server.url, function (err, res) {
if (err) throw err
expect(video.description).to.equal('my super description for pod 2')
expect(video.podUrl).to.equal('http://localhost:9002')
expect(video.magnetUri).to.exist
+ expect(video.duration).to.equal(5)
if (server.url !== 'http://localhost:9002') {
expect(video.isLocal).to.be.false
}
// All pods should have the same magnet Uri
- if (base_magnet === null) {
- base_magnet = video.magnetUri
+ if (baseMagnet === null) {
+ baseMagnet = video.magnetUri
} else {
expect(video.magnetUri).to.equal.magnetUri
}
- callback()
+ utils.testImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ callback()
+ })
})
}, done)
}
function (err) {
if (err) throw err
- let base_magnet = null
+ let baseMagnet = null
// All pods should have this video
async.each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) {
const videos = res.body
expect(videos).to.be.an('array')
expect(videos.length).to.equal(4)
- const video1 = videos[2]
+
+ // We not sure about the order of the two last uploads
+ let video1 = null
+ let video2 = null
+ if (videos[2].name === 'my super name for pod 3') {
+ video1 = videos[2]
+ video2 = videos[3]
+ } else {
+ video1 = videos[3]
+ video2 = videos[2]
+ }
+
expect(video1.name).to.equal('my super name for pod 3')
expect(video1.description).to.equal('my super description for pod 3')
expect(video1.podUrl).to.equal('http://localhost:9003')
expect(video1.magnetUri).to.exist
+ expect(video1.duration).to.equal(5)
- const video2 = videos[3]
expect(video2.name).to.equal('my super name for pod 3-2')
expect(video2.description).to.equal('my super description for pod 3-2')
expect(video2.podUrl).to.equal('http://localhost:9003')
expect(video2.magnetUri).to.exist
+ expect(video2.duration).to.equal(5)
if (server.url !== 'http://localhost:9003') {
expect(video1.isLocal).to.be.false
}
// All pods should have the same magnet Uri
- if (base_magnet === null) {
- base_magnet = video2.magnetUri
+ if (baseMagnet === null) {
+ baseMagnet = video2.magnetUri
} else {
expect(video2.magnetUri).to.equal.magnetUri
}
- callback()
+ utils.testImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ utils.testImage(server.url, 'video_short.webm', video2.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ callback()
+ })
+ })
})
}, done)
}
if (err) throw err
const video = res.body[0]
- to_remove.push(res.body[2].id)
- to_remove.push(res.body[3].id)
+ toRemove.push(res.body[2].id)
+ toRemove.push(res.body[3].id)
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist
async.series([
function (next) {
- utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[0], next)
+ utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next)
},
function (next) {
- utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[1], next)
+ utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1], next)
}],
function (err) {
if (err) throw err
expect(videos).to.be.an('array')
expect(videos.length).to.equal(2)
expect(videos[0].id).not.to.equal(videos[1].id)
- expect(videos[0].id).not.to.equal(to_remove[0])
- expect(videos[1].id).not.to.equal(to_remove[0])
- expect(videos[0].id).not.to.equal(to_remove[1])
- expect(videos[1].id).not.to.equal(to_remove[1])
+ expect(videos[0].id).not.to.equal(toRemove[0])
+ expect(videos[1].id).not.to.equal(toRemove[0])
+ expect(videos[0].id).not.to.equal(toRemove[1])
+ expect(videos[1].id).not.to.equal(toRemove[1])
callback()
})