]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/peertube.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / cli / peertube.ts
index b8c0b1f795e541cea386e2d0574793304e791faf..27fbde02de7848f38fd8e0cc6c12c461662ab1ce 100644 (file)
@@ -1,4 +1,4 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 import { expect } from 'chai'
@@ -7,14 +7,17 @@ import {
   buildAbsoluteFixturePath,
   cleanupTests,
   createUser,
+  doubleFollow,
   execCLI,
   flushAndRunServer,
   getEnvCli,
+  getLocalIdByUUID,
   getVideo,
   getVideosList,
-  getVideosListWithToken, removeVideo,
+  removeVideo,
   ServerInfo,
   setAccessTokensToServers,
+  uploadVideoAndGetId,
   userLogin,
   waitJobs
 } from '../../../shared/extra-utils'
@@ -101,7 +104,7 @@ describe('Test CLI wrapper', function () {
 
       const videos: Video[] = res.body.data
 
-      const video: VideoDetails = (await getVideo(server.url, videos[ 0 ].uuid)).body
+      const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body
 
       expect(video.name).to.equal('test upload')
       expect(video.support).to.equal('support_text')
@@ -210,6 +213,81 @@ describe('Test CLI wrapper', function () {
     })
   })
 
+  describe('Manage video redundancies', function () {
+    let anotherServer: ServerInfo
+    let video1Server2: number
+    let servers: ServerInfo[]
+
+    before(async function () {
+      this.timeout(120000)
+
+      anotherServer = await flushAndRunServer(2)
+      await setAccessTokensToServers([ anotherServer ])
+
+      await doubleFollow(server, anotherServer)
+
+      servers = [ server, anotherServer ]
+      await waitJobs(servers)
+
+      const uuid = (await uploadVideoAndGetId({ server: anotherServer, videoName: 'super video' })).uuid
+      await waitJobs(servers)
+
+      video1Server2 = await getLocalIdByUUID(server.url, uuid)
+    })
+
+    it('Should add a redundancy', async function () {
+      this.timeout(60000)
+
+      const env = getEnvCli(server)
+
+      const params = `add --video ${video1Server2}`
+
+      await execCLI(`${env} ${cmd} redundancy ${params}`)
+
+      await waitJobs(servers)
+    })
+
+    it('Should list redundancies', async function () {
+      this.timeout(60000)
+
+      {
+        const env = getEnvCli(server)
+
+        const params = 'list-my-redundancies'
+        const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`)
+
+        expect(stdout).to.contain('super video')
+        expect(stdout).to.contain(`localhost:${server.port}`)
+      }
+    })
+
+    it('Should remove a redundancy', async function () {
+      this.timeout(60000)
+
+      const env = getEnvCli(server)
+
+      const params = `remove --video ${video1Server2}`
+
+      await execCLI(`${env} ${cmd} redundancy ${params}`)
+
+      await waitJobs(servers)
+
+      {
+        const env = getEnvCli(server)
+        const params = 'list-my-redundancies'
+        const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`)
+
+        expect(stdout).to.not.contain('super video')
+      }
+    })
+
+    after(async function () {
+      this.timeout(10000)
+
+      await cleanupTests([ anotherServer ])
+    })
+  })
+
   after(async function () {
     this.timeout(10000)