diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-13 13:53:28 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-13 13:53:28 +0200 |
commit | 1205823fece15f249e0dbad42e096cf9b81c3ba5 (patch) | |
tree | c1291b443aa530cc37cd9389620186ec2043e441 /server/tests/cli | |
parent | 1a12f66d631d28a5a58ebbcd274426f2e6e5d203 (diff) | |
download | PeerTube-1205823fece15f249e0dbad42e096cf9b81c3ba5.tar.gz PeerTube-1205823fece15f249e0dbad42e096cf9b81c3ba5.tar.zst PeerTube-1205823fece15f249e0dbad42e096cf9b81c3ba5.zip |
Add ability to override CLI import attributes
Diffstat (limited to 'server/tests/cli')
-rw-r--r-- | server/tests/cli/peertube.ts | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 6e7bf0843..0a8a98334 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts | |||
@@ -10,18 +10,20 @@ import { | |||
10 | execCLI, | 10 | execCLI, |
11 | flushAndRunServer, | 11 | flushAndRunServer, |
12 | getEnvCli, | 12 | getEnvCli, |
13 | getMyUserInformation, | 13 | getVideo, |
14 | getVideosList, | 14 | getVideosList, |
15 | getVideosListWithToken, removeVideo, | ||
15 | ServerInfo, | 16 | ServerInfo, |
16 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
17 | userLogin, waitJobs | 18 | userLogin, |
19 | waitJobs | ||
18 | } from '../../../shared/extra-utils' | 20 | } from '../../../shared/extra-utils' |
19 | import { User, Video } from '../../../shared' | 21 | import { Video, VideoDetails } from '../../../shared' |
20 | import { getYoutubeVideoUrl } from '../../../shared/extra-utils/videos/video-imports' | 22 | import { getYoutubeVideoUrl } from '../../../shared/extra-utils/videos/video-imports' |
21 | 23 | ||
22 | describe('Test CLI wrapper', function () { | 24 | describe('Test CLI wrapper', function () { |
23 | let server: ServerInfo | 25 | let server: ServerInfo |
24 | let channelId: number | 26 | let userAccessToken: string |
25 | 27 | ||
26 | const cmd = 'node ./dist/server/tools/peertube.js' | 28 | const cmd = 'node ./dist/server/tools/peertube.js' |
27 | 29 | ||
@@ -33,11 +35,11 @@ describe('Test CLI wrapper', function () { | |||
33 | 35 | ||
34 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' }) | 36 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' }) |
35 | 37 | ||
36 | const userAccessToken = await userLogin(server, { username: 'user_1', password: 'super_password' }) | 38 | userAccessToken = await userLogin(server, { username: 'user_1', password: 'super_password' }) |
37 | 39 | ||
38 | { | 40 | { |
39 | const res = await addVideoChannel(server.url, userAccessToken, { name: 'user_channel', displayName: 'User channel' }) | 41 | const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } |
40 | channelId = res.body.videoChannel.id | 42 | await addVideoChannel(server.url, userAccessToken, args) |
41 | } | 43 | } |
42 | }) | 44 | }) |
43 | 45 | ||
@@ -82,7 +84,7 @@ describe('Test CLI wrapper', function () { | |||
82 | 84 | ||
83 | const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') | 85 | const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') |
84 | 86 | ||
85 | const params = `-f ${fixture} --video-name 'test upload' --channel-id ${channelId}` | 87 | const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` |
86 | 88 | ||
87 | await execCLI(`${env} ${cmd} upload ${params}`) | 89 | await execCLI(`${env} ${cmd} upload ${params}`) |
88 | }) | 90 | }) |
@@ -93,8 +95,12 @@ describe('Test CLI wrapper', function () { | |||
93 | expect(res.body.total).to.equal(1) | 95 | expect(res.body.total).to.equal(1) |
94 | 96 | ||
95 | const videos: Video[] = res.body.data | 97 | const videos: Video[] = res.body.data |
96 | expect(videos[0].name).to.equal('test upload') | 98 | |
97 | expect(videos[0].channel.name).to.equal('user_channel') | 99 | const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body |
100 | |||
101 | expect(video.name).to.equal('test upload') | ||
102 | expect(video.support).to.equal('support_text') | ||
103 | expect(video.channel.name).to.equal('user_channel') | ||
98 | }) | 104 | }) |
99 | 105 | ||
100 | it('Should import a video', async function () { | 106 | it('Should import a video', async function () { |
@@ -102,7 +108,7 @@ describe('Test CLI wrapper', function () { | |||
102 | 108 | ||
103 | const env = getEnvCli(server) | 109 | const env = getEnvCli(server) |
104 | 110 | ||
105 | const params = `--target-url ${getYoutubeVideoUrl()} --channel-id ${channelId}` | 111 | const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` |
106 | 112 | ||
107 | await execCLI(`${env} ${cmd} import ${params}`) | 113 | await execCLI(`${env} ${cmd} import ${params}`) |
108 | }) | 114 | }) |
@@ -118,9 +124,41 @@ describe('Test CLI wrapper', function () { | |||
118 | 124 | ||
119 | const videos: Video[] = res.body.data | 125 | const videos: Video[] = res.body.data |
120 | const video = videos.find(v => v.name === 'small video - youtube') | 126 | const video = videos.find(v => v.name === 'small video - youtube') |
121 | |||
122 | expect(video).to.not.be.undefined | 127 | expect(video).to.not.be.undefined |
123 | expect(video.channel.name).to.equal('user_channel') | 128 | |
129 | const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body | ||
130 | expect(videoDetails.channel.name).to.equal('user_channel') | ||
131 | expect(videoDetails.support).to.equal('super support text') | ||
132 | expect(videoDetails.nsfw).to.be.false | ||
133 | |||
134 | // So we can reimport it | ||
135 | await removeVideo(server.url, userAccessToken, video.id) | ||
136 | }) | ||
137 | |||
138 | it('Should import and override some imported attributes', async function () { | ||
139 | this.timeout(60000) | ||
140 | |||
141 | const env = getEnvCli(server) | ||
142 | |||
143 | const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` | ||
144 | |||
145 | await execCLI(`${env} ${cmd} import ${params}`) | ||
146 | |||
147 | await waitJobs([ server ]) | ||
148 | |||
149 | { | ||
150 | const res = await getVideosList(server.url) | ||
151 | expect(res.body.total).to.equal(2) | ||
152 | |||
153 | const videos: Video[] = res.body.data | ||
154 | const video = videos.find(v => v.name === 'toto') | ||
155 | expect(video).to.not.be.undefined | ||
156 | |||
157 | const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body | ||
158 | expect(videoDetails.channel.name).to.equal('user_channel') | ||
159 | expect(videoDetails.support).to.equal('support') | ||
160 | expect(videoDetails.nsfw).to.be.true | ||
161 | } | ||
124 | }) | 162 | }) |
125 | 163 | ||
126 | it('Should remove the auth user', async function () { | 164 | it('Should remove the auth user', async function () { |