aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
commit99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch)
treec9e04ccfcc5496d2300d7c26db5833e494b4cdad /server/tests/utils/videos.js
parentfcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff)
parent91cc839af88730ba55f84997c56b85ea100070a7 (diff)
downloadPeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.gz
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.zst
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.zip
Merge branch 'postgresql'
Diffstat (limited to 'server/tests/utils/videos.js')
-rw-r--r--server/tests/utils/videos.js84
1 files changed, 63 insertions, 21 deletions
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js
index 536093db1..f94368437 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 --------------------
@@ -25,7 +26,7 @@ function getAllVideosListBy (url, end) {
25 26
26 request(url) 27 request(url)
27 .get(path) 28 .get(path)
28 .query({ sort: 'createdDate' }) 29 .query({ sort: 'createdAt' })
29 .query({ start: 0 }) 30 .query({ start: 0 })
30 .query({ count: 10000 }) 31 .query({ count: 10000 })
31 .set('Accept', 'application/json') 32 .set('Accept', 'application/json')
@@ -57,17 +58,25 @@ function getVideosList (url, end) {
57 .end(end) 58 .end(end)
58} 59}
59 60
60function getVideosListPagination (url, start, count, end) { 61function getVideosListPagination (url, start, count, sort, end) {
62 if (!end) {
63 end = sort
64 sort = null
65 }
66
61 const path = '/api/v1/videos' 67 const path = '/api/v1/videos'
62 68
63 request(url) 69 const req = request(url)
64 .get(path) 70 .get(path)
65 .query({ start: start }) 71 .query({ start: start })
66 .query({ count: count }) 72 .query({ count: count })
67 .set('Accept', 'application/json') 73
68 .expect(200) 74 if (sort) req.query({ sort })
69 .expect('Content-Type', /json/) 75
70 .end(end) 76 req.set('Accept', 'application/json')
77 .expect(200)
78 .expect('Content-Type', /json/)
79 .end(end)
71} 80}
72 81
73function getVideosListSort (url, sort, end) { 82function getVideosListSort (url, sort, end) {
@@ -115,18 +124,26 @@ function searchVideo (url, search, field, end) {
115 .end(end) 124 .end(end)
116} 125}
117 126
118function searchVideoWithPagination (url, search, field, start, count, end) { 127function searchVideoWithPagination (url, search, field, start, count, sort, end) {
128 if (!end) {
129 end = sort
130 sort = null
131 }
132
119 const path = '/api/v1/videos' 133 const path = '/api/v1/videos'
120 134
121 request(url) 135 const req = request(url)
122 .get(path + '/search/' + search) 136 .get(path + '/search/' + search)
123 .query({ start: start }) 137 .query({ start: start })
124 .query({ count: count }) 138 .query({ count: count })
125 .query({ field: field }) 139 .query({ field: field })
126 .set('Accept', 'application/json') 140
127 .expect(200) 141 if (sort) req.query({ sort })
128 .expect('Content-Type', /json/) 142
129 .end(end) 143 req.set('Accept', 'application/json')
144 .expect(200)
145 .expect('Content-Type', /json/)
146 .end(end)
130} 147}
131 148
132function searchVideoWithSort (url, search, sort, end) { 149function searchVideoWithSort (url, search, sort, end) {
@@ -194,6 +211,31 @@ function uploadVideo (url, accessToken, name, description, tags, fixture, specia
194 .end(end) 211 .end(end)
195} 212}
196 213
214function updateVideo (url, accessToken, id, name, description, tags, specialStatus, end) {
215 if (!end) {
216 end = specialStatus
217 specialStatus = 204
218 }
219
220 const path = '/api/v1/videos/' + id
221
222 const req = request(url)
223 .put(path)
224 .set('Accept', 'application/json')
225 .set('Authorization', 'Bearer ' + accessToken)
226
227 if (name) req.field('name', name)
228 if (description) req.field('description', description)
229
230 if (tags) {
231 for (let i = 0; i < tags.length; i++) {
232 req.field('tags[' + i + ']', tags[i])
233 }
234 }
235
236 req.expect(specialStatus).end(end)
237}
238
197// --------------------------------------------------------------------------- 239// ---------------------------------------------------------------------------
198 240
199module.exports = videosUtils 241module.exports = videosUtils