]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/update-host.ts
Add runner server tests
[github/Chocobozzz/PeerTube.git] / server / tests / cli / update-host.ts
index 43fbaec305d8489322a1008546d3c3cdc78b26fc..386c384e6f92c4981288921ce004a0a17a693904 100644 (file)
@@ -1,17 +1,17 @@
 /* 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,
   createSingleServer,
   killallServers,
   makeActivityPubGetRequest,
-  parseTorrentVideo,
   PeerTubeServer,
   setAccessTokensToServers,
   waitJobs
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
+import { parseTorrentVideo } from '../shared'
 
 describe('Test update host scripts', function () {
   let server: PeerTubeServer
@@ -67,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 })
 
@@ -84,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)
     }
   })
 
@@ -96,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)
     }
   })
 
@@ -108,22 +108,22 @@ describe('Test update host scripts', function () {
 
     for (const video of data) {
       const videoDetails = await server.videos.get({ id: video.id })
-      const files = videoDetails.files.concat(videoDetails.streamingPlaylists[0].files)
+      const files = getAllFiles(videoDetails)
 
       expect(files).to.have.lengthOf(8)
 
       for (const file of files) {
-        expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
-        expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F')
+        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, file)
-        const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
+        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/')
+        expect(torrent.urlList[0]).to.contain('http://127.0.0.1:9002/static/')
       }
     }
   })