X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fupdate-host.ts;h=386c384e6f92c4981288921ce004a0a17a693904;hb=d102de1b38f2877463529c3b27bd35ffef4fd8bf;hp=d2d19645637b7e1ff928944242dd103fb6a7fb91;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index d2d196456..386c384e6 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -1,21 +1,20 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { expect } from 'chai' +import { getAllFiles } from '@shared/core-utils' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, makeActivityPubGetRequest, - parseTorrentVideo, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, waitJobs -} from '@shared/extra-utils' +} from '@shared/server-commands' +import { parseTorrentVideo } from '../shared' describe('Test update host scripts', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(60000) @@ -26,7 +25,7 @@ describe('Test update host scripts', function () { } } // Run server 2 to have transcoding enabled - server = await flushAndRunServer(2, overrideConfig) + server = await createSingleServer(2, overrideConfig) await setAccessTokensToServers([ server ]) // Upload two videos for our needs @@ -56,7 +55,7 @@ describe('Test update host scripts', function () { await killallServers([ server ]) // Run server with standard configuration - await reRunServer(server) + await server.run() await server.cli.execWithEnv(`npm run update-host`) }) @@ -68,7 +67,7 @@ describe('Test update host scripts', function () { for (const video of data) { const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid) - expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) + expect(body.id).to.equal('http://127.0.0.1:9002/videos/watch/' + video.uuid) const videoDetails = await server.videos.get({ id: video.uuid }) @@ -85,7 +84,7 @@ describe('Test update host scripts', function () { for (const channel of data) { const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) - expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) + expect(body.id).to.equal('http://127.0.0.1:9002/video-channels/' + channel.name) } }) @@ -97,7 +96,7 @@ describe('Test update host scripts', function () { const usernameWithDomain = account.name const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain) - expect(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain) + expect(body.id).to.equal('http://127.0.0.1:9002/accounts/' + usernameWithDomain) } }) @@ -109,21 +108,22 @@ describe('Test update host scripts', function () { for (const video of data) { const videoDetails = await server.videos.get({ id: video.id }) + const files = getAllFiles(videoDetails) - expect(videoDetails.files).to.have.lengthOf(4) + expect(files).to.have.lengthOf(8) - for (const file of videoDetails.files) { - expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') - expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') + for (const file of files) { + expect(file.magnetUri).to.contain('127.0.0.1%3A9002%2Ftracker%2Fsocket') + expect(file.magnetUri).to.contain('127.0.0.1%3A9002%2Fstatic%2F') - const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id) - const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') + const torrent = await parseTorrentVideo(server, file) + const announceWS = torrent.announce.find(a => a === 'ws://127.0.0.1:9002/tracker/socket') expect(announceWS).to.not.be.undefined - const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce') + const announceHttp = torrent.announce.find(a => a === 'http://127.0.0.1:9002/tracker/announce') expect(announceHttp).to.not.be.undefined - expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') + expect(torrent.urlList[0]).to.contain('http://127.0.0.1:9002/static/') } } })