aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/peertube.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-05 16:37:50 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:16 +0200
commit329619b3453479f76c049816b7403b86e9d45cb5 (patch)
treee522940946402a4284d356f2cde8e0dcbe29b289 /server/tests/cli/peertube.ts
parenta6a79eae0d8564099b6957e76d7a18528d9ef124 (diff)
downloadPeerTube-329619b3453479f76c049816b7403b86e9d45cb5.tar.gz
PeerTube-329619b3453479f76c049816b7403b86e9d45cb5.tar.zst
PeerTube-329619b3453479f76c049816b7403b86e9d45cb5.zip
Introduce CLI command
Diffstat (limited to 'server/tests/cli/peertube.ts')
-rw-r--r--server/tests/cli/peertube.ts82
1 files changed, 26 insertions, 56 deletions
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 }