aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli')
-rw-r--r--server/tests/cli/create-import-video-file-job.ts14
-rw-r--r--server/tests/cli/create-transcoding-job.ts23
-rw-r--r--server/tests/cli/optimize-old-videos.ts6
-rw-r--r--server/tests/cli/peertube.ts82
-rw-r--r--server/tests/cli/plugins.ts13
-rw-r--r--server/tests/cli/print-transcode-command.ts7
-rw-r--r--server/tests/cli/prune-storage.ts7
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts5
-rw-r--r--server/tests/cli/reset-password.ts10
-rw-r--r--server/tests/cli/update-host.ts14
10 files changed, 62 insertions, 119 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 49758ff56..8a23a94de 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -6,9 +6,7 @@ import { VideoFile } from '@shared/models/videos/video-file.model'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 execCLI,
10 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
11 getEnvCli,
12 getVideo, 10 getVideo,
13 getVideosList, 11 getVideosList,
14 ServerInfo, 12 ServerInfo,
@@ -57,8 +55,8 @@ describe('Test create import video jobs', function () {
57 }) 55 })
58 56
59 it('Should run a import job on video 1 with a lower resolution', async function () { 57 it('Should run a import job on video 1 with a lower resolution', async function () {
60 const env = getEnvCli(servers[0]) 58 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
61 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) 59 await servers[0].cliCommand.execWithEnv(command)
62 60
63 await waitJobs(servers) 61 await waitJobs(servers)
64 62
@@ -77,8 +75,8 @@ describe('Test create import video jobs', function () {
77 }) 75 })
78 76
79 it('Should run a import job on video 2 with the same resolution and a different extension', async function () { 77 it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
80 const env = getEnvCli(servers[1]) 78 const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`
81 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) 79 await servers[1].cliCommand.execWithEnv(command)
82 80
83 await waitJobs(servers) 81 await waitJobs(servers)
84 82
@@ -99,8 +97,8 @@ describe('Test create import video jobs', function () {
99 }) 97 })
100 98
101 it('Should run a import job on video 2 with the same resolution and the same extension', async function () { 99 it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
102 const env = getEnvCli(servers[0]) 100 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
103 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`) 101 await servers[0].cliCommand.execWithEnv(command)
104 102
105 await waitJobs(servers) 103 await waitJobs(servers)
106 104
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index 5bc1687cd..be46dec25 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -2,13 +2,10 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
8 doubleFollow, 7 doubleFollow,
9 execCLI,
10 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
11 getEnvCli,
12 getVideo, 9 getVideo,
13 getVideosList, 10 getVideosList,
14 ServerInfo, 11 ServerInfo,
@@ -17,6 +14,7 @@ import {
17 uploadVideo 14 uploadVideo
18} from '../../../shared/extra-utils' 15} from '../../../shared/extra-utils'
19import { waitJobs } from '../../../shared/extra-utils/server/jobs' 16import { waitJobs } from '../../../shared/extra-utils/server/jobs'
17import { VideoDetails } from '../../../shared/models/videos'
20 18
21const expect = chai.expect 19const expect = chai.expect
22 20
@@ -81,9 +79,7 @@ describe('Test create transcoding jobs', function () {
81 it('Should run a transcoding job on video 2', async function () { 79 it('Should run a transcoding job on video 2', async function () {
82 this.timeout(60000) 80 this.timeout(60000)
83 81
84 const env = getEnvCli(servers[0]) 82 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
85 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[1]}`)
86
87 await waitJobs(servers) 83 await waitJobs(servers)
88 84
89 for (const server of servers) { 85 for (const server of servers) {
@@ -123,8 +119,7 @@ describe('Test create transcoding jobs', function () {
123 it('Should run a transcoding job on video 1 with resolution', async function () { 119 it('Should run a transcoding job on video 1 with resolution', async function () {
124 this.timeout(60000) 120 this.timeout(60000)
125 121
126 const env = getEnvCli(servers[0]) 122 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
127 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
128 123
129 await waitJobs(servers) 124 await waitJobs(servers)
130 125
@@ -147,8 +142,7 @@ describe('Test create transcoding jobs', function () {
147 it('Should generate an HLS resolution', async function () { 142 it('Should generate an HLS resolution', async function () {
148 this.timeout(120000) 143 this.timeout(120000)
149 144
150 const env = getEnvCli(servers[0]) 145 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
151 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
152 146
153 await waitJobs(servers) 147 await waitJobs(servers)
154 148
@@ -168,8 +162,7 @@ describe('Test create transcoding jobs', function () {
168 it('Should not duplicate an HLS resolution', async function () { 162 it('Should not duplicate an HLS resolution', async function () {
169 this.timeout(120000) 163 this.timeout(120000)
170 164
171 const env = getEnvCli(servers[0]) 165 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
172 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
173 166
174 await waitJobs(servers) 167 await waitJobs(servers)
175 168
@@ -186,8 +179,7 @@ describe('Test create transcoding jobs', function () {
186 it('Should generate all HLS resolutions', async function () { 179 it('Should generate all HLS resolutions', async function () {
187 this.timeout(120000) 180 this.timeout(120000)
188 181
189 const env = getEnvCli(servers[0]) 182 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
190 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
191 183
192 await waitJobs(servers) 184 await waitJobs(servers)
193 185
@@ -209,8 +201,7 @@ describe('Test create transcoding jobs', function () {
209 config.transcoding.hls.enabled = true 201 config.transcoding.hls.enabled = true
210 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) 202 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
211 203
212 const env = getEnvCli(servers[0]) 204 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
213 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[4]}`)
214 205
215 await waitJobs(servers) 206 await waitJobs(servers)
216 207
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 91a1c9cc4..bd15012fe 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -7,10 +7,8 @@ import {
7 buildServerDirectory, 7 buildServerDirectory,
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 execCLI,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 generateHighBitrateVideo, 11 generateHighBitrateVideo,
13 getEnvCli,
14 getVideo, 12 getVideo,
15 getVideosList, 13 getVideosList,
16 ServerInfo, 14 ServerInfo,
@@ -73,9 +71,7 @@ describe('Test optimize old videos', function () {
73 it('Should run optimize script', async function () { 71 it('Should run optimize script', async function () {
74 this.timeout(200000) 72 this.timeout(200000)
75 73
76 const env = getEnvCli(servers[0]) 74 await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos')
77 await execCLI(`${env} npm run optimize-old-videos`)
78
79 await waitJobs(servers) 75 await waitJobs(servers)
80 76
81 for (const server of servers) { 77 for (const server of servers) {
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index fcf7e2e2e..0a4f54ffa 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -8,11 +8,10 @@ import {
8 areHttpImportTestsDisabled, 8 areHttpImportTestsDisabled,
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
11 CLICommand,
11 createUser, 12 createUser,
12 doubleFollow, 13 doubleFollow,
13 execCLI,
14 flushAndRunServer, 14 flushAndRunServer,
15 getEnvCli,
16 getLocalIdByUUID, 15 getLocalIdByUUID,
17 getVideo, 16 getVideo,
18 getVideosList, 17 getVideosList,
@@ -30,6 +29,8 @@ describe('Test CLI wrapper', function () {
30 let server: ServerInfo 29 let server: ServerInfo
31 let userAccessToken: string 30 let userAccessToken: string
32 31
32 let cliCommand: CLICommand
33
33 const cmd = 'node ./dist/server/tools/peertube.js' 34 const cmd = 'node ./dist/server/tools/peertube.js'
34 35
35 before(async function () { 36 before(async function () {
@@ -46,6 +47,8 @@ describe('Test CLI wrapper', function () {
46 const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } 47 const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
47 await addVideoChannel(server.url, userAccessToken, args) 48 await addVideoChannel(server.url, userAccessToken, args)
48 } 49 }
50
51 cliCommand = server.cliCommand
49 }) 52 })
50 53
51 describe('Authentication and instance selection', function () { 54 describe('Authentication and instance selection', function () {
@@ -53,46 +56,38 @@ describe('Test CLI wrapper', function () {
53 it('Should display no selected instance', async function () { 56 it('Should display no selected instance', async function () {
54 this.timeout(60000) 57 this.timeout(60000)
55 58
56 const env = getEnvCli(server) 59 const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
57 const stdout = await execCLI(`${env} ${cmd} --help`)
58
59 expect(stdout).to.contain('no instance selected') 60 expect(stdout).to.contain('no instance selected')
60 }) 61 })
61 62
62 it('Should add a user', async function () { 63 it('Should add a user', async function () {
63 this.timeout(60000) 64 this.timeout(60000)
64 65
65 const env = getEnvCli(server) 66 await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U user_1 -p super_password`)
66 await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`)
67 }) 67 })
68 68
69 it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () { 69 it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () {
70 this.timeout(60000) 70 this.timeout(60000)
71 71
72 const env = getEnvCli(server) 72 let fullServerURL = server.url + '/'
73 let fullServerURL 73
74 fullServerURL = server.url + '/' 74 await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
75 await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
76 75
77 fullServerURL = server.url + '/asdfasdf' 76 fullServerURL = server.url + '/asdfasdf'
78 await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) 77 await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
79 }) 78 })
80 79
81 it('Should default to this user', async function () { 80 it('Should default to this user', async function () {
82 this.timeout(60000) 81 this.timeout(60000)
83 82
84 const env = getEnvCli(server) 83 const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
85 const stdout = await execCLI(`${env} ${cmd} --help`)
86
87 expect(stdout).to.contain(`instance ${server.url} selected`) 84 expect(stdout).to.contain(`instance ${server.url} selected`)
88 }) 85 })
89 86
90 it('Should remember the user', async function () { 87 it('Should remember the user', async function () {
91 this.timeout(60000) 88 this.timeout(60000)
92 89
93 const env = getEnvCli(server) 90 const stdout = await cliCommand.execWithEnv(`${cmd} auth list`)
94 const stdout = await execCLI(`${env} ${cmd} auth list`)
95
96 expect(stdout).to.contain(server.url) 91 expect(stdout).to.contain(server.url)
97 }) 92 })
98 }) 93 })
@@ -102,13 +97,10 @@ describe('Test CLI wrapper', function () {
102 it('Should upload a video', async function () { 97 it('Should upload a video', async function () {
103 this.timeout(60000) 98 this.timeout(60000)
104 99
105 const env = getEnvCli(server)
106
107 const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') 100 const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4')
108
109 const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` 101 const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'`
110 102
111 await execCLI(`${env} ${cmd} upload ${params}`) 103 await cliCommand.execWithEnv(`${cmd} upload ${params}`)
112 }) 104 })
113 105
114 it('Should have the video uploaded', async function () { 106 it('Should have the video uploaded', async function () {
@@ -130,11 +122,8 @@ describe('Test CLI wrapper', function () {
130 122
131 this.timeout(60000) 123 this.timeout(60000)
132 124
133 const env = getEnvCli(server)
134
135 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` 125 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel`
136 126 await cliCommand.execWithEnv(`${cmd} import ${params}`)
137 await execCLI(`${env} ${cmd} import ${params}`)
138 }) 127 })
139 128
140 it('Should have imported the video', async function () { 129 it('Should have imported the video', async function () {
@@ -166,11 +155,8 @@ describe('Test CLI wrapper', function () {
166 155
167 this.timeout(60000) 156 this.timeout(60000)
168 157
169 const env = getEnvCli(server)
170
171 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` 158 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support`
172 159 await cliCommand.execWithEnv(`${cmd} import ${params}`)
173 await execCLI(`${env} ${cmd} import ${params}`)
174 160
175 await waitJobs([ server ]) 161 await waitJobs([ server ])
176 162
@@ -194,18 +180,14 @@ describe('Test CLI wrapper', function () {
194 describe('Admin auth', function () { 180 describe('Admin auth', function () {
195 181
196 it('Should remove the auth user', async function () { 182 it('Should remove the auth user', async function () {
197 const env = getEnvCli(server) 183 await cliCommand.execWithEnv(`${cmd} auth del ${server.url}`)
198
199 await execCLI(`${env} ${cmd} auth del ${server.url}`)
200
201 const stdout = await execCLI(`${env} ${cmd} --help`)
202 184
185 const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
203 expect(stdout).to.contain('no instance selected') 186 expect(stdout).to.contain('no instance selected')
204 }) 187 })
205 188
206 it('Should add the admin user', async function () { 189 it('Should add the admin user', async function () {
207 const env = getEnvCli(server) 190 await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`)
208 await execCLI(`${env} ${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`)
209 }) 191 })
210 }) 192 })
211 193
@@ -214,8 +196,7 @@ describe('Test CLI wrapper', function () {
214 it('Should install a plugin', async function () { 196 it('Should install a plugin', async function () {
215 this.timeout(60000) 197 this.timeout(60000)
216 198
217 const env = getEnvCli(server) 199 await cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world`)
218 await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`)
219 }) 200 })
220 201
221 it('Should have registered settings', async function () { 202 it('Should have registered settings', async function () {
@@ -223,15 +204,13 @@ describe('Test CLI wrapper', function () {
223 }) 204 })
224 205
225 it('Should list installed plugins', async function () { 206 it('Should list installed plugins', async function () {
226 const env = getEnvCli(server) 207 const res = await cliCommand.execWithEnv(`${cmd} plugins list`)
227 const res = await execCLI(`${env} ${cmd} plugins list`)
228 208
229 expect(res).to.contain('peertube-plugin-hello-world') 209 expect(res).to.contain('peertube-plugin-hello-world')
230 }) 210 })
231 211
232 it('Should uninstall the plugin', async function () { 212 it('Should uninstall the plugin', async function () {
233 const env = getEnvCli(server) 213 const res = await cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`)
234 const res = await execCLI(`${env} ${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`)
235 214
236 expect(res).to.not.contain('peertube-plugin-hello-world') 215 expect(res).to.not.contain('peertube-plugin-hello-world')
237 }) 216 })
@@ -262,11 +241,8 @@ describe('Test CLI wrapper', function () {
262 it('Should add a redundancy', async function () { 241 it('Should add a redundancy', async function () {
263 this.timeout(60000) 242 this.timeout(60000)
264 243
265 const env = getEnvCli(server)
266
267 const params = `add --video ${video1Server2}` 244 const params = `add --video ${video1Server2}`
268 245 await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
269 await execCLI(`${env} ${cmd} redundancy ${params}`)
270 246
271 await waitJobs(servers) 247 await waitJobs(servers)
272 }) 248 })
@@ -275,10 +251,8 @@ describe('Test CLI wrapper', function () {
275 this.timeout(60000) 251 this.timeout(60000)
276 252
277 { 253 {
278 const env = getEnvCli(server)
279
280 const params = 'list-my-redundancies' 254 const params = 'list-my-redundancies'
281 const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) 255 const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
282 256
283 expect(stdout).to.contain('super video') 257 expect(stdout).to.contain('super video')
284 expect(stdout).to.contain(`localhost:${server.port}`) 258 expect(stdout).to.contain(`localhost:${server.port}`)
@@ -288,18 +262,14 @@ describe('Test CLI wrapper', function () {
288 it('Should remove a redundancy', async function () { 262 it('Should remove a redundancy', async function () {
289 this.timeout(60000) 263 this.timeout(60000)
290 264
291 const env = getEnvCli(server)
292
293 const params = `remove --video ${video1Server2}` 265 const params = `remove --video ${video1Server2}`
294 266 await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
295 await execCLI(`${env} ${cmd} redundancy ${params}`)
296 267
297 await waitJobs(servers) 268 await waitJobs(servers)
298 269
299 { 270 {
300 const env = getEnvCli(server)
301 const params = 'list-my-redundancies' 271 const params = 'list-my-redundancies'
302 const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) 272 const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
303 273
304 expect(stdout).to.not.contain('super video') 274 expect(stdout).to.not.contain('super video')
305 } 275 }
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
index 7f19f14b7..efdc20748 100644
--- a/server/tests/cli/plugins.ts
+++ b/server/tests/cli/plugins.ts
@@ -1,12 +1,11 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 execCLI,
7 flushAndRunServer, 7 flushAndRunServer,
8 getConfig, 8 getConfig,
9 getEnvCli,
10 getPluginTestPath, 9 getPluginTestPath,
11 killallServers, 10 killallServers,
12 reRunServer, 11 reRunServer,
@@ -14,7 +13,6 @@ import {
14 setAccessTokensToServers 13 setAccessTokensToServers
15} from '../../../shared/extra-utils' 14} from '../../../shared/extra-utils'
16import { ServerConfig } from '../../../shared/models/server' 15import { ServerConfig } from '../../../shared/models/server'
17import { expect } from 'chai'
18 16
19describe('Test plugin scripts', function () { 17describe('Test plugin scripts', function () {
20 let server: ServerInfo 18 let server: ServerInfo
@@ -31,15 +29,13 @@ describe('Test plugin scripts', function () {
31 29
32 const packagePath = getPluginTestPath() 30 const packagePath = getPluginTestPath()
33 31
34 const env = getEnvCli(server) 32 await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
35 await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
36 }) 33 })
37 34
38 it('Should install a theme from stateless CLI', async function () { 35 it('Should install a theme from stateless CLI', async function () {
39 this.timeout(60000) 36 this.timeout(60000)
40 37
41 const env = getEnvCli(server) 38 await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
42 await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
43 }) 39 })
44 40
45 it('Should have the theme and the plugin registered when we restart peertube', async function () { 41 it('Should have the theme and the plugin registered when we restart peertube', async function () {
@@ -63,8 +59,7 @@ describe('Test plugin scripts', function () {
63 it('Should uninstall a plugin from stateless CLI', async function () { 59 it('Should uninstall a plugin from stateless CLI', async function () {
64 this.timeout(60000) 60 this.timeout(60000)
65 61
66 const env = getEnvCli(server) 62 await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
67 await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
68 }) 63 })
69 64
70 it('Should have removed the plugin on another peertube restart', async function () { 65 it('Should have removed the plugin on another peertube restart', async function () {
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts
index 2d7255db7..3a7969e68 100644
--- a/server/tests/cli/print-transcode-command.ts
+++ b/server/tests/cli/print-transcode-command.ts
@@ -2,14 +2,15 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { execCLI } from '../../../shared/extra-utils' 5import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
6import { CLICommand } from '@shared/extra-utils'
6import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' 7import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos'
7import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' 8import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
8import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
9 9
10const expect = chai.expect 10const expect = chai.expect
11 11
12describe('Test create transcoding jobs', function () { 12describe('Test create transcoding jobs', function () {
13
13 it('Should print the correct command for each resolution', async function () { 14 it('Should print the correct command for each resolution', async function () {
14 const fixturePath = 'server/tests/fixtures/video_short.webm' 15 const fixturePath = 'server/tests/fixtures/video_short.webm'
15 const fps = await getVideoFileFPS(fixturePath) 16 const fps = await getVideoFileFPS(fixturePath)
@@ -19,7 +20,7 @@ describe('Test create transcoding jobs', function () {
19 VideoResolution.H_720P, 20 VideoResolution.H_720P,
20 VideoResolution.H_1080P 21 VideoResolution.H_1080P
21 ]) { 22 ]) {
22 const command = await execCLI(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) 23 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`)
23 const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) 24 const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate)
24 25
25 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) 26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index a0af09de8..81f91105c 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -9,12 +9,11 @@ import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-code
9import { 9import {
10 buildServerDirectory, 10 buildServerDirectory,
11 cleanupTests, 11 cleanupTests,
12 CLICommand,
12 createVideoPlaylist, 13 createVideoPlaylist,
13 doubleFollow, 14 doubleFollow,
14 execCLI,
15 flushAndRunMultipleServers, 15 flushAndRunMultipleServers,
16 getAccount, 16 getAccount,
17 getEnvCli,
18 killallServers, 17 killallServers,
19 makeGetRequest, 18 makeGetRequest,
20 ServerInfo, 19 ServerInfo,
@@ -193,8 +192,8 @@ describe('Test prune storage scripts', function () {
193 it('Should run prune storage', async function () { 192 it('Should run prune storage', async function () {
194 this.timeout(30000) 193 this.timeout(30000)
195 194
196 const env = getEnvCli(servers[0]) 195 const env = servers[0].cliCommand.getEnv()
197 await execCLI(`echo y | ${env} npm run prune-storage`) 196 await CLICommand.exec(`echo y | ${env} npm run prune-storage`)
198 }) 197 })
199 198
200 it('Should have removed files', async function () { 199 it('Should have removed files', async function () {
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index 8acb9f263..1b460e9c0 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -7,9 +7,7 @@ import {
7 buildServerDirectory, 7 buildServerDirectory,
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 execCLI,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 getEnvCli,
13 getVideo, 11 getVideo,
14 makeRawRequest, 12 makeRawRequest,
15 ServerInfo, 13 ServerInfo,
@@ -91,8 +89,7 @@ describe('Test regenerate thumbnails script', function () {
91 it('Should regenerate local thumbnails from the CLI', async function () { 89 it('Should regenerate local thumbnails from the CLI', async function () {
92 this.timeout(15000) 90 this.timeout(15000)
93 91
94 const env = getEnvCli(servers[0]) 92 await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`)
95 await execCLI(`${env} npm run regenerate-thumbnails`)
96 }) 93 })
97 94
98 it('Should have generated new thumbnail files', async function () { 95 it('Should have generated new thumbnail files', async function () {
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
index a84463b33..97a6eae15 100644
--- a/server/tests/cli/reset-password.ts
+++ b/server/tests/cli/reset-password.ts
@@ -1,16 +1,14 @@
1import 'mocha' 1import 'mocha'
2 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { 3import {
4 cleanupTests, 4 cleanupTests,
5 CLICommand,
5 createUser, 6 createUser,
6 execCLI,
7 flushAndRunServer, 7 flushAndRunServer,
8 getEnvCli,
9 login, 8 login,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers 10 setAccessTokensToServers
12} from '../../../shared/extra-utils' 11} from '../../../shared/extra-utils'
13import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
14 12
15describe('Test reset password scripts', function () { 13describe('Test reset password scripts', function () {
16 let server: ServerInfo 14 let server: ServerInfo
@@ -26,8 +24,8 @@ describe('Test reset password scripts', function () {
26 it('Should change the user password from CLI', async function () { 24 it('Should change the user password from CLI', async function () {
27 this.timeout(60000) 25 this.timeout(60000)
28 26
29 const env = getEnvCli(server) 27 const env = server.cliCommand.getEnv()
30 await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`) 28 await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
31 29
32 await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200) 30 await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200)
33 }) 31 })
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index 2070f16f5..1b1a76aef 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -2,27 +2,26 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos'
6import { waitJobs } from '../../../shared/extra-utils/server/jobs'
7import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
8import { 5import {
9 addVideoChannel, 6 addVideoChannel,
10 cleanupTests, 7 cleanupTests,
11 createUser, 8 createUser,
12 execCLI,
13 flushAndRunServer, 9 flushAndRunServer,
14 getEnvCli,
15 getVideo, 10 getVideo,
16 getVideoChannelsList, 11 getVideoChannelsList,
17 getVideosList, 12 getVideosList,
18 killallServers, 13 killallServers,
19 makeActivityPubGetRequest, 14 makeActivityPubGetRequest,
20 parseTorrentVideo, reRunServer, 15 parseTorrentVideo,
16 reRunServer,
21 ServerInfo, 17 ServerInfo,
22 setAccessTokensToServers, 18 setAccessTokensToServers,
23 uploadVideo 19 uploadVideo
24} from '../../../shared/extra-utils' 20} from '../../../shared/extra-utils'
21import { waitJobs } from '../../../shared/extra-utils/server/jobs'
25import { getAccountsList } from '../../../shared/extra-utils/users/accounts' 22import { getAccountsList } from '../../../shared/extra-utils/users/accounts'
23import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
24import { VideoDetails } from '../../../shared/models/videos'
26 25
27const expect = chai.expect 26const expect = chai.expect
28 27
@@ -72,8 +71,7 @@ describe('Test update host scripts', function () {
72 // Run server with standard configuration 71 // Run server with standard configuration
73 await reRunServer(server) 72 await reRunServer(server)
74 73
75 const env = getEnvCli(server) 74 await server.cliCommand.execWithEnv(`npm run update-host`)
76 await execCLI(`${env} npm run update-host`)
77 }) 75 })
78 76
79 it('Should have updated videos url', async function () { 77 it('Should have updated videos url', async function () {