]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/update-host.ts
Fix import tests
[github/Chocobozzz/PeerTube.git] / server / tests / cli / update-host.ts
index d2d19645637b7e1ff928944242dd103fb6a7fb91..7c49efd20767497550b9cf6ff5496d3fddbd5db5 100644 (file)
@@ -4,18 +4,18 @@ import 'mocha'
 import { expect } from 'chai'
 import {
   cleanupTests,
-  flushAndRunServer,
+  createSingleServer,
   killallServers,
   makeActivityPubGetRequest,
   parseTorrentVideo,
-  reRunServer,
-  ServerInfo,
+  PeerTubeServer,
   setAccessTokensToServers,
   waitJobs
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
+import { getAllFiles } from '../shared'
 
 describe('Test update host scripts', function () {
-  let server: ServerInfo
+  let server: PeerTubeServer
 
   before(async function () {
     this.timeout(60000)
@@ -26,7 +26,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 +56,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`)
   })
@@ -109,21 +109,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) {
+      for (const file of files) {
         expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
-        expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F')
+        expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F')
 
-        const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id)
+        const torrent = await parseTorrentVideo(server, file)
         const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
         expect(announceWS).to.not.be.undefined
 
         const announceHttp = torrent.announce.find(a => a === 'http://localhost: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://localhost:9002/static/')
       }
     }
   })