2 import * as chai from 'chai'
3 const expect = chai.expect
14 setAccessTokensToServers,
19 describe('Test update host scripts', function () {
20 let server: ServerInfo
22 before(async function () {
27 const overrideConfig = {
32 // Run server 2 to have transcoding enabled
33 server = await runServer(2, overrideConfig)
34 await setAccessTokensToServers([ server ])
36 // Upload two videos for our needs
37 const videoAttributes = {}
38 await uploadVideo(server.url, server.accessToken, videoAttributes)
39 await uploadVideo(server.url, server.accessToken, videoAttributes)
43 it('Should update torrent hosts', async function () {
46 killallServers([ server ])
47 // Run server with standard configuration
48 server = await runServer(2)
50 const env = getEnvCli(server)
51 await execCLI(`${env} npm run update-host`)
53 const res = await getVideosList(server.url)
54 const videos = res.body.data
55 expect(videos).to.have.lengthOf(2)
57 for (const video of videos) {
58 expect(video.files).to.have.lengthOf(4)
60 for (const file of video.files) {
61 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
62 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F')
64 const torrent = await parseTorrentVideo(server, video.uuid, file.resolution)
65 expect(torrent.announce[0]).to.equal('ws://localhost:9002/tracker/socket')
66 expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed')
71 after(async function () {
72 killallServers([ server ])
74 // Keep the logs if the test failed