diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 11:36:23 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 11:36:23 +0200 |
commit | 93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 (patch) | |
tree | b0a1f77af7ab54dc5f58f569fcd1e9d84b04c533 /server/tests/api/multiple-pods.js | |
parent | 69f224587e99d56008e1fa129d0641840a486620 (diff) | |
download | PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.gz PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.zst PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.zip |
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
Diffstat (limited to 'server/tests/api/multiple-pods.js')
-rw-r--r-- | server/tests/api/multiple-pods.js | 69 |
1 files changed, 54 insertions, 15 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index abbc2caf4..b281cc249 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js | |||
@@ -121,13 +121,21 @@ describe('Test multiple pods', function () { | |||
121 | expect(video.nsfw).to.be.ok | 121 | expect(video.nsfw).to.be.ok |
122 | expect(video.description).to.equal('my super description for pod 1') | 122 | expect(video.description).to.equal('my super description for pod 1') |
123 | expect(video.podHost).to.equal('localhost:9001') | 123 | expect(video.podHost).to.equal('localhost:9001') |
124 | expect(video.magnetUri).to.exist | ||
125 | expect(video.duration).to.equal(10) | 124 | expect(video.duration).to.equal(10) |
126 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) | 125 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) |
127 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 126 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
128 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | 127 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true |
129 | expect(video.author).to.equal('root') | 128 | expect(video.author).to.equal('root') |
130 | 129 | ||
130 | expect(video.files).to.have.lengthOf(1) | ||
131 | |||
132 | const file = video.files[0] | ||
133 | const magnetUri = file.magnetUri | ||
134 | expect(file.magnetUri).to.exist | ||
135 | expect(file.resolution).to.equal(0) | ||
136 | expect(file.resolutionLabel).to.equal('original') | ||
137 | expect(file.size).to.equal(572456) | ||
138 | |||
131 | if (server.url !== 'http://localhost:9001') { | 139 | if (server.url !== 'http://localhost:9001') { |
132 | expect(video.isLocal).to.be.false | 140 | expect(video.isLocal).to.be.false |
133 | } else { | 141 | } else { |
@@ -136,9 +144,9 @@ describe('Test multiple pods', function () { | |||
136 | 144 | ||
137 | // All pods should have the same magnet Uri | 145 | // All pods should have the same magnet Uri |
138 | if (baseMagnet === null) { | 146 | if (baseMagnet === null) { |
139 | baseMagnet = video.magnetUri | 147 | baseMagnet = magnetUri |
140 | } else { | 148 | } else { |
141 | expect(video.magnetUri).to.equal.magnetUri | 149 | expect(baseMagnet).to.equal(magnetUri) |
142 | } | 150 | } |
143 | 151 | ||
144 | videosUtils.testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) { | 152 | videosUtils.testVideoImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) { |
@@ -198,13 +206,21 @@ describe('Test multiple pods', function () { | |||
198 | expect(video.nsfw).to.be.true | 206 | expect(video.nsfw).to.be.true |
199 | expect(video.description).to.equal('my super description for pod 2') | 207 | expect(video.description).to.equal('my super description for pod 2') |
200 | expect(video.podHost).to.equal('localhost:9002') | 208 | expect(video.podHost).to.equal('localhost:9002') |
201 | expect(video.magnetUri).to.exist | ||
202 | expect(video.duration).to.equal(5) | 209 | expect(video.duration).to.equal(5) |
203 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) | 210 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) |
204 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 211 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
205 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | 212 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true |
206 | expect(video.author).to.equal('root') | 213 | expect(video.author).to.equal('root') |
207 | 214 | ||
215 | expect(video.files).to.have.lengthOf(1) | ||
216 | |||
217 | const file = video.files[0] | ||
218 | const magnetUri = file.magnetUri | ||
219 | expect(file.magnetUri).to.exist | ||
220 | expect(file.resolution).to.equal(0) | ||
221 | expect(file.resolutionLabel).to.equal('original') | ||
222 | expect(file.size).to.equal(942961) | ||
223 | |||
208 | if (server.url !== 'http://localhost:9002') { | 224 | if (server.url !== 'http://localhost:9002') { |
209 | expect(video.isLocal).to.be.false | 225 | expect(video.isLocal).to.be.false |
210 | } else { | 226 | } else { |
@@ -213,9 +229,9 @@ describe('Test multiple pods', function () { | |||
213 | 229 | ||
214 | // All pods should have the same magnet Uri | 230 | // All pods should have the same magnet Uri |
215 | if (baseMagnet === null) { | 231 | if (baseMagnet === null) { |
216 | baseMagnet = video.magnetUri | 232 | baseMagnet = magnetUri |
217 | } else { | 233 | } else { |
218 | expect(video.magnetUri).to.equal.magnetUri | 234 | expect(baseMagnet).to.equal(magnetUri) |
219 | } | 235 | } |
220 | 236 | ||
221 | videosUtils.testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) { | 237 | videosUtils.testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) { |
@@ -297,13 +313,21 @@ describe('Test multiple pods', function () { | |||
297 | expect(video1.nsfw).to.be.ok | 313 | expect(video1.nsfw).to.be.ok |
298 | expect(video1.description).to.equal('my super description for pod 3') | 314 | expect(video1.description).to.equal('my super description for pod 3') |
299 | expect(video1.podHost).to.equal('localhost:9003') | 315 | expect(video1.podHost).to.equal('localhost:9003') |
300 | expect(video1.magnetUri).to.exist | ||
301 | expect(video1.duration).to.equal(5) | 316 | expect(video1.duration).to.equal(5) |
302 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) | 317 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) |
303 | expect(video1.author).to.equal('root') | 318 | expect(video1.author).to.equal('root') |
304 | expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true | 319 | expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true |
305 | expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true | 320 | expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true |
306 | 321 | ||
322 | expect(video1.files).to.have.lengthOf(1) | ||
323 | |||
324 | const file1 = video1.files[0] | ||
325 | const magnetUri1 = file1.magnetUri | ||
326 | expect(file1.magnetUri).to.exist | ||
327 | expect(file1.resolution).to.equal(0) | ||
328 | expect(file1.resolutionLabel).to.equal('original') | ||
329 | expect(file1.size).to.equal(292677) | ||
330 | |||
307 | expect(video2.name).to.equal('my super name for pod 3-2') | 331 | expect(video2.name).to.equal('my super name for pod 3-2') |
308 | expect(video2.category).to.equal(7) | 332 | expect(video2.category).to.equal(7) |
309 | expect(video2.categoryLabel).to.equal('Gaming') | 333 | expect(video2.categoryLabel).to.equal('Gaming') |
@@ -314,13 +338,21 @@ describe('Test multiple pods', function () { | |||
314 | expect(video2.nsfw).to.be.false | 338 | expect(video2.nsfw).to.be.false |
315 | expect(video2.description).to.equal('my super description for pod 3-2') | 339 | expect(video2.description).to.equal('my super description for pod 3-2') |
316 | expect(video2.podHost).to.equal('localhost:9003') | 340 | expect(video2.podHost).to.equal('localhost:9003') |
317 | expect(video2.magnetUri).to.exist | ||
318 | expect(video2.duration).to.equal(5) | 341 | expect(video2.duration).to.equal(5) |
319 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) | 342 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) |
320 | expect(video2.author).to.equal('root') | 343 | expect(video2.author).to.equal('root') |
321 | expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true | 344 | expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true |
322 | expect(miscsUtils.dateIsValid(video2.updatedAt)).to.be.true | 345 | expect(miscsUtils.dateIsValid(video2.updatedAt)).to.be.true |
323 | 346 | ||
347 | expect(video2.files).to.have.lengthOf(1) | ||
348 | |||
349 | const file2 = video2.files[0] | ||
350 | const magnetUri2 = file2.magnetUri | ||
351 | expect(file2.magnetUri).to.exist | ||
352 | expect(file2.resolution).to.equal(0) | ||
353 | expect(file2.resolutionLabel).to.equal('original') | ||
354 | expect(file2.size).to.equal(218910) | ||
355 | |||
324 | if (server.url !== 'http://localhost:9003') { | 356 | if (server.url !== 'http://localhost:9003') { |
325 | expect(video1.isLocal).to.be.false | 357 | expect(video1.isLocal).to.be.false |
326 | expect(video2.isLocal).to.be.false | 358 | expect(video2.isLocal).to.be.false |
@@ -331,9 +363,9 @@ describe('Test multiple pods', function () { | |||
331 | 363 | ||
332 | // All pods should have the same magnet Uri | 364 | // All pods should have the same magnet Uri |
333 | if (baseMagnet === null) { | 365 | if (baseMagnet === null) { |
334 | baseMagnet = video2.magnetUri | 366 | baseMagnet = magnetUri2 |
335 | } else { | 367 | } else { |
336 | expect(video2.magnetUri).to.equal.magnetUri | 368 | expect(baseMagnet).to.equal(magnetUri2) |
337 | } | 369 | } |
338 | 370 | ||
339 | videosUtils.testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) { | 371 | videosUtils.testVideoImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) { |
@@ -366,7 +398,7 @@ describe('Test multiple pods', function () { | |||
366 | toRemove.push(res.body.data[2]) | 398 | toRemove.push(res.body.data[2]) |
367 | toRemove.push(res.body.data[3]) | 399 | toRemove.push(res.body.data[3]) |
368 | 400 | ||
369 | webtorrent.add(video.magnetUri, function (torrent) { | 401 | webtorrent.add(video.files[0].magnetUri, function (torrent) { |
370 | expect(torrent.files).to.exist | 402 | expect(torrent.files).to.exist |
371 | expect(torrent.files.length).to.equal(1) | 403 | expect(torrent.files.length).to.equal(1) |
372 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 404 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
@@ -385,7 +417,7 @@ describe('Test multiple pods', function () { | |||
385 | 417 | ||
386 | const video = res.body.data[1] | 418 | const video = res.body.data[1] |
387 | 419 | ||
388 | webtorrent.add(video.magnetUri, function (torrent) { | 420 | webtorrent.add(video.files[0].magnetUri, function (torrent) { |
389 | expect(torrent.files).to.exist | 421 | expect(torrent.files).to.exist |
390 | expect(torrent.files.length).to.equal(1) | 422 | expect(torrent.files.length).to.equal(1) |
391 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 423 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
@@ -404,7 +436,7 @@ describe('Test multiple pods', function () { | |||
404 | 436 | ||
405 | const video = res.body.data[2] | 437 | const video = res.body.data[2] |
406 | 438 | ||
407 | webtorrent.add(video.magnetUri, function (torrent) { | 439 | webtorrent.add(video.files[0].magnetUri, function (torrent) { |
408 | expect(torrent.files).to.exist | 440 | expect(torrent.files).to.exist |
409 | expect(torrent.files.length).to.equal(1) | 441 | expect(torrent.files.length).to.equal(1) |
410 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 442 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
@@ -423,7 +455,7 @@ describe('Test multiple pods', function () { | |||
423 | 455 | ||
424 | const video = res.body.data[3] | 456 | const video = res.body.data[3] |
425 | 457 | ||
426 | webtorrent.add(video.magnetUri, function (torrent) { | 458 | webtorrent.add(video.files[0].magnetUri, function (torrent) { |
427 | expect(torrent.files).to.exist | 459 | expect(torrent.files).to.exist |
428 | expect(torrent.files.length).to.equal(1) | 460 | expect(torrent.files.length).to.equal(1) |
429 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 461 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
@@ -700,11 +732,18 @@ describe('Test multiple pods', function () { | |||
700 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | 732 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) |
701 | expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true | 733 | expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true |
702 | 734 | ||
735 | const file = videoUpdated.files[0] | ||
736 | const magnetUri = file.magnetUri | ||
737 | expect(file.magnetUri).to.exist | ||
738 | expect(file.resolution).to.equal(0) | ||
739 | expect(file.resolutionLabel).to.equal('original') | ||
740 | expect(file.size).to.equal(292677) | ||
741 | |||
703 | videosUtils.testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath, function (err, test) { | 742 | videosUtils.testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath, function (err, test) { |
704 | if (err) throw err | 743 | if (err) throw err |
705 | expect(test).to.equal(true) | 744 | expect(test).to.equal(true) |
706 | 745 | ||
707 | webtorrent.add(videoUpdated.magnetUri, function (torrent) { | 746 | webtorrent.add(videoUpdated.files[0].magnetUri, function (torrent) { |
708 | expect(torrent.files).to.exist | 747 | expect(torrent.files).to.exist |
709 | expect(torrent.files.length).to.equal(1) | 748 | expect(torrent.files.length).to.equal(1) |
710 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 749 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |