aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-29 19:07:05 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-29 19:07:05 +0100
commit7b1f49de22c40ae121ddb3c399b2540ba56fd414 (patch)
tree269e5dc7c2ebe4147319f1ee8e8b7f3c74549149 /server/tests/utils/videos.js
parent4ff0d86208dafbdd07beb6286fd93c795db8a95f (diff)
downloadPeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.tar.gz
PeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.tar.zst
PeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.zip
Server: add ability to update a video
Diffstat (limited to 'server/tests/utils/videos.js')
-rw-r--r--server/tests/utils/videos.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js
index 5c120597f..beafd3cf5 100644
--- a/server/tests/utils/videos.js
+++ b/server/tests/utils/videos.js
@@ -15,7 +15,8 @@ const videosUtils = {
15 searchVideoWithPagination, 15 searchVideoWithPagination,
16 searchVideoWithSort, 16 searchVideoWithSort,
17 testVideoImage, 17 testVideoImage,
18 uploadVideo 18 uploadVideo,
19 updateVideo
19} 20}
20 21
21// ---------------------- Export functions -------------------- 22// ---------------------- Export functions --------------------
@@ -194,6 +195,31 @@ function uploadVideo (url, accessToken, name, description, tags, fixture, specia
194 .end(end) 195 .end(end)
195} 196}
196 197
198function updateVideo (url, accessToken, id, name, description, tags, specialStatus, end) {
199 if (!end) {
200 end = specialStatus
201 specialStatus = 204
202 }
203
204 const path = '/api/v1/videos/' + id
205
206 const req = request(url)
207 .put(path)
208 .set('Accept', 'application/json')
209 .set('Authorization', 'Bearer ' + accessToken)
210
211 if (name) req.field('name', name)
212 if (description) req.field('description', description)
213
214 if (tags) {
215 for (let i = 0; i < tags.length; i++) {
216 req.field('tags[' + i + ']', tags[i])
217 }
218 }
219
220 req.expect(specialStatus).end(end)
221}
222
197// --------------------------------------------------------------------------- 223// ---------------------------------------------------------------------------
198 224
199module.exports = videosUtils 225module.exports = videosUtils