aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-11 21:50:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-19 21:22:28 +0100
commitfeb4bdfd9b46e87aadfa7c0d5338cde887d1f58c (patch)
tree2abc9fbc9569760e218fd52835850b757344b420 /server/tests/api
parent108626609eda75e4ecc0a83a650a4d53c46220e0 (diff)
downloadPeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.gz
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.zst
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.zip
First version with PostgreSQL
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params.js6
-rw-r--r--server/tests/api/friends-basic.js4
-rw-r--r--server/tests/api/multiple-pods.js8
-rw-r--r--server/tests/api/requests.js29
-rw-r--r--server/tests/api/single-pod.js16
-rw-r--r--server/tests/api/users.js8
6 files changed, 23 insertions, 48 deletions
diff --git a/server/tests/api/check-params.js b/server/tests/api/check-params.js
index 444c2fc55..d9e51770c 100644
--- a/server/tests/api/check-params.js
+++ b/server/tests/api/check-params.js
@@ -465,7 +465,7 @@ describe('Test parameters validator', function () {
465 465
466 it('Should return 404 with an incorrect video', function (done) { 466 it('Should return 404 with an incorrect video', function (done) {
467 request(server.url) 467 request(server.url)
468 .get(path + '123456789012345678901234') 468 .get(path + '4da6fde3-88f7-4d16-b119-108df5630b06')
469 .set('Accept', 'application/json') 469 .set('Accept', 'application/json')
470 .expect(404, done) 470 .expect(404, done)
471 }) 471 })
@@ -490,7 +490,7 @@ describe('Test parameters validator', function () {
490 490
491 it('Should fail with a video which does not exist', function (done) { 491 it('Should fail with a video which does not exist', function (done) {
492 request(server.url) 492 request(server.url)
493 .delete(path + '123456789012345678901234') 493 .delete(path + '4da6fde3-88f7-4d16-b119-108df5630b06')
494 .set('Authorization', 'Bearer ' + server.accessToken) 494 .set('Authorization', 'Bearer ' + server.accessToken)
495 .expect(404, done) 495 .expect(404, done)
496 }) 496 })
@@ -711,7 +711,7 @@ describe('Test parameters validator', function () {
711 711
712 it('Should return 404 with a non existing id', function (done) { 712 it('Should return 404 with a non existing id', function (done) {
713 request(server.url) 713 request(server.url)
714 .delete(path + '579f982228c99c221d8092b8') 714 .delete(path + '45')
715 .set('Authorization', 'Bearer ' + server.accessToken) 715 .set('Authorization', 'Bearer ' + server.accessToken)
716 .expect(404, done) 716 .expect(404, done)
717 }) 717 })
diff --git a/server/tests/api/friends-basic.js b/server/tests/api/friends-basic.js
index a871f9838..3a904dbd7 100644
--- a/server/tests/api/friends-basic.js
+++ b/server/tests/api/friends-basic.js
@@ -97,7 +97,7 @@ describe('Test basic friends', function () {
97 const pod = result[0] 97 const pod = result[0]
98 expect(pod.host).to.equal(servers[2].host) 98 expect(pod.host).to.equal(servers[2].host)
99 expect(pod.score).to.equal(20) 99 expect(pod.score).to.equal(20)
100 expect(miscsUtils.dateIsValid(pod.createdDate)).to.be.true 100 expect(miscsUtils.dateIsValid(pod.createdAt)).to.be.true
101 101
102 next() 102 next()
103 }) 103 })
@@ -114,7 +114,7 @@ describe('Test basic friends', function () {
114 const pod = result[0] 114 const pod = result[0]
115 expect(pod.host).to.equal(servers[1].host) 115 expect(pod.host).to.equal(servers[1].host)
116 expect(pod.score).to.equal(20) 116 expect(pod.score).to.equal(20)
117 expect(miscsUtils.dateIsValid(pod.createdDate)).to.be.true 117 expect(miscsUtils.dateIsValid(pod.createdAt)).to.be.true
118 118
119 next() 119 next()
120 }) 120 })
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index be278d7c5..f0fe59c5f 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -104,7 +104,7 @@ describe('Test multiple pods', function () {
104 expect(video.magnetUri).to.exist 104 expect(video.magnetUri).to.exist
105 expect(video.duration).to.equal(10) 105 expect(video.duration).to.equal(10)
106 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) 106 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
107 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 107 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
108 expect(video.author).to.equal('root') 108 expect(video.author).to.equal('root')
109 109
110 if (server.url !== 'http://localhost:9001') { 110 if (server.url !== 'http://localhost:9001') {
@@ -166,7 +166,7 @@ describe('Test multiple pods', function () {
166 expect(video.magnetUri).to.exist 166 expect(video.magnetUri).to.exist
167 expect(video.duration).to.equal(5) 167 expect(video.duration).to.equal(5)
168 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) 168 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
169 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 169 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
170 expect(video.author).to.equal('root') 170 expect(video.author).to.equal('root')
171 171
172 if (server.url !== 'http://localhost:9002') { 172 if (server.url !== 'http://localhost:9002') {
@@ -246,7 +246,7 @@ describe('Test multiple pods', function () {
246 expect(video1.duration).to.equal(5) 246 expect(video1.duration).to.equal(5)
247 expect(video1.tags).to.deep.equal([ 'tag1p3' ]) 247 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
248 expect(video1.author).to.equal('root') 248 expect(video1.author).to.equal('root')
249 expect(miscsUtils.dateIsValid(video1.createdDate)).to.be.true 249 expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true
250 250
251 expect(video2.name).to.equal('my super name for pod 3-2') 251 expect(video2.name).to.equal('my super name for pod 3-2')
252 expect(video2.description).to.equal('my super description for pod 3-2') 252 expect(video2.description).to.equal('my super description for pod 3-2')
@@ -255,7 +255,7 @@ describe('Test multiple pods', function () {
255 expect(video2.duration).to.equal(5) 255 expect(video2.duration).to.equal(5)
256 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) 256 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
257 expect(video2.author).to.equal('root') 257 expect(video2.author).to.equal('root')
258 expect(miscsUtils.dateIsValid(video2.createdDate)).to.be.true 258 expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true
259 259
260 if (server.url !== 'http://localhost:9003') { 260 if (server.url !== 'http://localhost:9003') {
261 expect(video1.isLocal).to.be.false 261 expect(video1.isLocal).to.be.false
diff --git a/server/tests/api/requests.js b/server/tests/api/requests.js
index af36f6e34..7e790b54b 100644
--- a/server/tests/api/requests.js
+++ b/server/tests/api/requests.js
@@ -69,7 +69,7 @@ describe('Test requests stats', function () {
69 }) 69 })
70 }) 70 })
71 71
72 it('Should have the correct request', function (done) { 72 it('Should have the correct total request', function (done) {
73 this.timeout(15000) 73 this.timeout(15000)
74 74
75 const server = servers[0] 75 const server = servers[0]
@@ -83,11 +83,7 @@ describe('Test requests stats', function () {
83 if (err) throw err 83 if (err) throw err
84 84
85 const body = res.body 85 const body = res.body
86 expect(body.requests).to.have.lengthOf(1) 86 expect(body.totalRequests).to.equal(1)
87
88 const request = body.requests[0]
89 expect(request.to).to.have.lengthOf(1)
90 expect(request.request.type).to.equal('add')
91 87
92 // Wait one cycle 88 // Wait one cycle
93 setTimeout(done, 10000) 89 setTimeout(done, 10000)
@@ -95,27 +91,6 @@ describe('Test requests stats', function () {
95 }) 91 })
96 }) 92 })
97 93
98 it('Should have the correct requests', function (done) {
99 const server = servers[0]
100
101 uploadVideo(server, function (err) {
102 if (err) throw err
103
104 getRequestsStats(server, function (err, res) {
105 if (err) throw err
106
107 const body = res.body
108 expect(body.requests).to.have.lengthOf(2)
109
110 const request = body.requests[1]
111 expect(request.to).to.have.lengthOf(1)
112 expect(request.request.type).to.equal('add')
113
114 done()
115 })
116 })
117 })
118
119 after(function (done) { 94 after(function (done) {
120 process.kill(-servers[0].app.pid) 95 process.kill(-servers[0].app.pid)
121 96
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index 65d1a7a65..aedecacf3 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -82,7 +82,7 @@ describe('Test a single pod', function () {
82 expect(video.author).to.equal('root') 82 expect(video.author).to.equal('root')
83 expect(video.isLocal).to.be.true 83 expect(video.isLocal).to.be.true
84 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 84 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
85 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 85 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
86 86
87 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 87 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
88 if (err) throw err 88 if (err) throw err
@@ -116,7 +116,7 @@ describe('Test a single pod', function () {
116 expect(video.author).to.equal('root') 116 expect(video.author).to.equal('root')
117 expect(video.isLocal).to.be.true 117 expect(video.isLocal).to.be.true
118 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 118 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
119 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 119 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
120 120
121 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 121 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
122 if (err) throw err 122 if (err) throw err
@@ -142,7 +142,7 @@ describe('Test a single pod', function () {
142 expect(video.author).to.equal('root') 142 expect(video.author).to.equal('root')
143 expect(video.isLocal).to.be.true 143 expect(video.isLocal).to.be.true
144 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 144 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
145 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 145 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
146 146
147 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 147 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
148 if (err) throw err 148 if (err) throw err
@@ -154,7 +154,7 @@ describe('Test a single pod', function () {
154 }) 154 })
155 155
156 it('Should search the video by podHost', function (done) { 156 it('Should search the video by podHost', function (done) {
157 videosUtils.searchVideo(server.url, '9001', 'podHost', function (err, res) { 157 videosUtils.searchVideo(server.url, '9001', 'host', function (err, res) {
158 if (err) throw err 158 if (err) throw err
159 159
160 expect(res.body.total).to.equal(1) 160 expect(res.body.total).to.equal(1)
@@ -168,7 +168,7 @@ describe('Test a single pod', function () {
168 expect(video.author).to.equal('root') 168 expect(video.author).to.equal('root')
169 expect(video.isLocal).to.be.true 169 expect(video.isLocal).to.be.true
170 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 170 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
171 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 171 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
172 172
173 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 173 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
174 if (err) throw err 174 if (err) throw err
@@ -194,7 +194,7 @@ describe('Test a single pod', function () {
194 expect(video.author).to.equal('root') 194 expect(video.author).to.equal('root')
195 expect(video.isLocal).to.be.true 195 expect(video.isLocal).to.be.true
196 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) 196 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
197 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 197 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
198 198
199 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 199 videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
200 if (err) throw err 200 if (err) throw err
@@ -425,7 +425,7 @@ describe('Test a single pod', function () {
425 }) 425 })
426 426
427 it('Should search all the 9001 port videos', function (done) { 427 it('Should search all the 9001 port videos', function (done) {
428 videosUtils.searchVideoWithPagination(server.url, '9001', 'podHost', 0, 15, function (err, res) { 428 videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15, function (err, res) {
429 if (err) throw err 429 if (err) throw err
430 430
431 const videos = res.body.data 431 const videos = res.body.data
@@ -437,7 +437,7 @@ describe('Test a single pod', function () {
437 }) 437 })
438 438
439 it('Should search all the localhost videos', function (done) { 439 it('Should search all the localhost videos', function (done) {
440 videosUtils.searchVideoWithPagination(server.url, 'localhost', 'podHost', 0, 15, function (err, res) { 440 videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15, function (err, res) {
441 if (err) throw err 441 if (err) throw err
442 442
443 const videos = res.body.data 443 const videos = res.body.data
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index 94267f104..e6d937eb0 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -261,8 +261,8 @@ describe('Test users', function () {
261 }) 261 })
262 }) 262 })
263 263
264 it('Should list only the second user by createdDate desc', function (done) { 264 it('Should list only the second user by createdAt desc', function (done) {
265 usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-createdDate', function (err, res) { 265 usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-createdAt', function (err, res) {
266 if (err) throw err 266 if (err) throw err
267 267
268 const result = res.body 268 const result = res.body
@@ -279,8 +279,8 @@ describe('Test users', function () {
279 }) 279 })
280 }) 280 })
281 281
282 it('Should list all the users by createdDate asc', function (done) { 282 it('Should list all the users by createdAt asc', function (done) {
283 usersUtils.getUsersListPaginationAndSort(server.url, 0, 2, 'createdDate', function (err, res) { 283 usersUtils.getUsersListPaginationAndSort(server.url, 0, 2, 'createdAt', function (err, res) {
284 if (err) throw err 284 if (err) throw err
285 285
286 const result = res.body 286 const result = res.body