1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 import { VideoDetails } from '../../../shared/models/videos'
6 const expect = chai.expect
17 setAccessTokensToServers,
23 describe('Test update host scripts', function () {
24 let server: ServerInfo
26 before(async function () {
31 const overrideConfig = {
36 // Run server 2 to have transcoding enabled
37 server = await runServer(2, overrideConfig)
38 await setAccessTokensToServers([ server ])
40 // Upload two videos for our needs
41 const videoAttributes = {}
42 await uploadVideo(server.url, server.accessToken, videoAttributes)
43 await uploadVideo(server.url, server.accessToken, videoAttributes)
47 it('Should update torrent hosts', async function () {
50 killallServers([ server ])
51 // Run server with standard configuration
52 server = await runServer(2)
54 const env = getEnvCli(server)
55 await execCLI(`${env} npm run update-host`)
57 const res = await getVideosList(server.url)
58 const videos = res.body.data
59 expect(videos).to.have.lengthOf(2)
61 for (const video of videos) {
62 const res2 = await getVideo(server.url, video.id)
63 const videoDetails: VideoDetails = res2.body
65 expect(videoDetails.files).to.have.lengthOf(4)
67 for (const file of videoDetails.files) {
68 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
69 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F')
71 const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id)
72 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
73 expect(announceWS).to.not.be.undefined
75 const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce')
76 expect(announceHttp).to.not.be.undefined
78 expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed')
83 after(async function () {
84 killallServers([ server ])
86 // Keep the logs if the test failed