1
0
Fork 0

Add tests for thumbnails

This commit is contained in:
Chocobozzz 2016-05-10 21:55:59 +02:00
parent cbe2f7c348
commit 9e5f374090
9 changed files with 85 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -110,8 +110,13 @@ describe('Test multiple pods', function () {
expect(video.magnetUri).to.equal.magnetUri expect(video.magnetUri).to.equal.magnetUri
} }
utils.testImage(server.url, 'video_short1.webm', video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
callback() callback()
}) })
})
}, done) }, done)
} }
) )
@ -160,8 +165,13 @@ describe('Test multiple pods', function () {
expect(video.magnetUri).to.equal.magnetUri expect(video.magnetUri).to.equal.magnetUri
} }
utils.testImage(server.url, 'video_short2.webm', video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
callback() callback()
}) })
})
}, done) }, done)
} }
) )
@ -231,8 +241,18 @@ describe('Test multiple pods', function () {
expect(video2.magnetUri).to.equal.magnetUri expect(video2.magnetUri).to.equal.magnetUri
} }
utils.testImage(server.url, 'video_short3.webm', video1.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
utils.testImage(server.url, 'video_short.webm', video2.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
callback() callback()
}) })
})
})
}, done) }, done)
} }
) )

View file

@ -76,6 +76,10 @@ describe('Test a single pod', function () {
expect(video.author).to.equal('root') expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true expect(video.isLocal).to.be.true
utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
video_id = video.id video_id = video.id
webtorrent.add(video.magnetUri, function (torrent) { webtorrent.add(video.magnetUri, function (torrent) {
@ -87,6 +91,7 @@ describe('Test a single pod', function () {
}) })
}) })
}) })
})
it('Should get the video', function (done) { it('Should get the video', function (done) {
// Yes, this could be long // Yes, this could be long
@ -103,6 +108,10 @@ describe('Test a single pod', function () {
expect(video.author).to.equal('root') expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true expect(video.isLocal).to.be.true
utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
webtorrent.add(video.magnetUri, function (torrent) { webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist expect(torrent.files).to.exist
expect(torrent.files.length).to.equal(1) expect(torrent.files.length).to.equal(1)
@ -112,6 +121,7 @@ describe('Test a single pod', function () {
}) })
}) })
}) })
})
it('Should search the video', function (done) { it('Should search the video', function (done) {
utils.searchVideo(server.url, 'my', function (err, res) { utils.searchVideo(server.url, 'my', function (err, res) {
@ -127,9 +137,14 @@ describe('Test a single pod', function () {
expect(video.author).to.equal('root') expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true expect(video.isLocal).to.be.true
utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
done() done()
}) })
}) })
})
it('Should not find a search', function (done) { it('Should not find a search', function (done) {
utils.searchVideo(server.url, 'hello', function (err, res) { utils.searchVideo(server.url, 'hello', function (err, res) {
@ -197,6 +212,24 @@ describe('Test a single pod', function () {
}) })
}) })
it('Should have the correct thumbnails', function (done) {
utils.getVideosList(server.url, function (err, res) {
const videos = res.body
async.each(videos, function (video, callback_each) {
if (err) throw err
const video_name = video.name.replace(' name', '')
utils.testImage(server.url, video_name, video.thumbnail_path, function (err, test) {
if (err) throw err
expect(test).to.equal(true)
callback_each()
})
}, done)
})
})
after(function (done) { after(function (done) {
process.kill(-server.app.pid) process.kill(-server.app.pid)
process.kill(-webtorrent.app.pid) process.kill(-webtorrent.app.pid)

View file

@ -3,6 +3,7 @@
const child_process = require('child_process') const child_process = require('child_process')
const exec = child_process.exec const exec = child_process.exec
const fork = child_process.fork const fork = child_process.fork
const fs = require('fs')
const pathUtils = require('path') const pathUtils = require('path')
const request = require('supertest') const request = require('supertest')
@ -19,6 +20,7 @@ const testUtils = {
flushAndRunMultipleServers: flushAndRunMultipleServers, flushAndRunMultipleServers: flushAndRunMultipleServers,
runServer: runServer, runServer: runServer,
searchVideo: searchVideo, searchVideo: searchVideo,
testImage: testImage,
uploadVideo: uploadVideo uploadVideo: uploadVideo
} }
@ -252,6 +254,21 @@ function searchVideo (url, search, end) {
.end(end) .end(end)
} }
function testImage (url, video_name, image_path, callback) {
request(url)
.get(image_path)
.expect(200)
.end(function (err, res) {
if (err) return callback(err)
fs.readFile(pathUtils.join(__dirname, 'fixtures', video_name + '.jpg'), function (err, data) {
if (err) return callback(err)
callback(null, data.equals(res.body))
})
})
}
function uploadVideo (url, access_token, name, description, fixture, special_status, end) { function uploadVideo (url, access_token, name, description, fixture, special_status, end) {
if (!end) { if (!end) {
end = special_status end = special_status