diff options
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/videos.js | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js index 0aa6ec5a8..ad0d74076 100644 --- a/server/tests/utils/videos.js +++ b/server/tests/utils/videos.js | |||
@@ -193,7 +193,7 @@ function testVideoImage (url, videoName, imagePath, callback) { | |||
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | function uploadVideo (url, accessToken, name, category, description, tags, fixture, specialStatus, end) { | 196 | function uploadVideo (url, accessToken, videoAttributesArg, specialStatus, end) { |
197 | if (!end) { | 197 | if (!end) { |
198 | end = specialStatus | 198 | end = specialStatus |
199 | specialStatus = 204 | 199 | specialStatus = 204 |
@@ -201,23 +201,33 @@ function uploadVideo (url, accessToken, name, category, description, tags, fixtu | |||
201 | 201 | ||
202 | const path = '/api/v1/videos' | 202 | const path = '/api/v1/videos' |
203 | 203 | ||
204 | // Default attributes | ||
205 | let attributes = { | ||
206 | name: 'my super video', | ||
207 | category: 5, | ||
208 | description: 'my super description', | ||
209 | tags: [ 'tag' ], | ||
210 | fixture: 'video_short.webm' | ||
211 | } | ||
212 | attributes = Object.assign(attributes, videoAttributesArg) | ||
213 | |||
204 | const req = request(url) | 214 | const req = request(url) |
205 | .post(path) | 215 | .post(path) |
206 | .set('Accept', 'application/json') | 216 | .set('Accept', 'application/json') |
207 | .set('Authorization', 'Bearer ' + accessToken) | 217 | .set('Authorization', 'Bearer ' + accessToken) |
208 | .field('name', name) | 218 | .field('name', attributes.name) |
209 | .field('category', category) | 219 | .field('category', attributes.category) |
210 | .field('description', description) | 220 | .field('description', attributes.description) |
211 | 221 | ||
212 | for (let i = 0; i < tags.length; i++) { | 222 | for (let i = 0; i < attributes.tags.length; i++) { |
213 | req.field('tags[' + i + ']', tags[i]) | 223 | req.field('tags[' + i + ']', attributes.tags[i]) |
214 | } | 224 | } |
215 | 225 | ||
216 | let filepath = '' | 226 | let filepath = '' |
217 | if (pathUtils.isAbsolute(fixture)) { | 227 | if (pathUtils.isAbsolute(attributes.fixture)) { |
218 | filepath = fixture | 228 | filepath = attributes.fixture |
219 | } else { | 229 | } else { |
220 | filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', fixture) | 230 | filepath = pathUtils.join(__dirname, '..', 'api', 'fixtures', attributes.fixture) |
221 | } | 231 | } |
222 | 232 | ||
223 | req.attach('videofile', filepath) | 233 | req.attach('videofile', filepath) |
@@ -225,7 +235,7 @@ function uploadVideo (url, accessToken, name, category, description, tags, fixtu | |||
225 | .end(end) | 235 | .end(end) |
226 | } | 236 | } |
227 | 237 | ||
228 | function updateVideo (url, accessToken, id, name, category, description, tags, specialStatus, end) { | 238 | function updateVideo (url, accessToken, id, attributes, specialStatus, end) { |
229 | if (!end) { | 239 | if (!end) { |
230 | end = specialStatus | 240 | end = specialStatus |
231 | specialStatus = 204 | 241 | specialStatus = 204 |
@@ -238,13 +248,13 @@ function updateVideo (url, accessToken, id, name, category, description, tags, s | |||
238 | .set('Accept', 'application/json') | 248 | .set('Accept', 'application/json') |
239 | .set('Authorization', 'Bearer ' + accessToken) | 249 | .set('Authorization', 'Bearer ' + accessToken) |
240 | 250 | ||
241 | if (name) req.field('name', name) | 251 | if (attributes.name) req.field('name', attributes.name) |
242 | if (category) req.field('category', category) | 252 | if (attributes.category) req.field('category', attributes.category) |
243 | if (description) req.field('description', description) | 253 | if (attributes.description) req.field('description', attributes.description) |
244 | 254 | ||
245 | if (tags) { | 255 | if (attributes.tags) { |
246 | for (let i = 0; i < tags.length; i++) { | 256 | for (let i = 0; i < attributes.tags.length; i++) { |
247 | req.field('tags[' + i + ']', tags[i]) | 257 | req.field('tags[' + i + ']', attributes.tags[i]) |
248 | } | 258 | } |
249 | } | 259 | } |
250 | 260 | ||