]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - test/api/singlePod.js
4 var chai
= require('chai')
6 var expect
= chai
.expect
8 var webtorrent
= require(__dirname
+ '/../../src/webTorrentNode')
9 webtorrent
.silent
= true
11 var utils
= require('./utils')
13 describe('Test a single pod', function () {
18 before(function (done
) {
21 utils
.flushTests(function () {
22 utils
.runServer(1, function (app1
, url1
) {
26 webtorrent
.create({ host: 'client', port: '1' }, function () {
33 it('Should not have videos', function (done
) {
34 utils
.getVideosList(url
, function (err
, res
) {
37 expect(res
.body
).to
.be
.an('array')
38 expect(res
.body
.length
).to
.equal(0)
44 it('Should upload the video', function (done
) {
46 utils
.uploadVideo(url
, 'my super name', 'my super description', 'video_short.webm', done
)
49 it('Should seed the uploaded video', function (done
) {
50 // Yes, this could be long
53 utils
.getVideosList(url
, function (err
, res
) {
56 expect(res
.body
).to
.be
.an('array')
57 expect(res
.body
.length
).to
.equal(1)
59 var video
= res
.body
[0]
60 expect(video
.name
).to
.equal('my super name')
61 expect(video
.description
).to
.equal('my super description')
62 expect(video
.podUrl
).to
.equal('http://localhost:9001')
63 expect(video
.magnetUri
).to
.exist
67 webtorrent
.add(video
.magnetUri
, function (torrent
) {
68 expect(torrent
.files
).to
.exist
69 expect(torrent
.files
.length
).to
.equal(1)
70 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
77 it('Should search the video', function (done
) {
78 utils
.searchVideo(url
, 'my', function (err
, res
) {
81 expect(res
.body
).to
.be
.an('array')
82 expect(res
.body
.length
).to
.equal(1)
84 var video
= res
.body
[0]
85 expect(video
.name
).to
.equal('my super name')
86 expect(video
.description
).to
.equal('my super description')
87 expect(video
.podUrl
).to
.equal('http://localhost:9001')
88 expect(video
.magnetUri
).to
.exist
94 it('Should not find a search', function (done
) {
95 utils
.searchVideo(url
, 'hello', function (err
, res
) {
98 expect(res
.body
).to
.be
.an('array')
99 expect(res
.body
.length
).to
.equal(0)
105 it('Should remove the video', function (done
) {
106 utils
.removeVideo(url
, video_id
, function (err
) {
109 fs
.readdir(__dirname
+ '/../../test1/uploads/', function (err
, files
) {
112 expect(files
.length
).to
.equal(0)
118 it('Should not have videos', function (done
) {
119 utils
.getVideosList(url
, function (err
, res
) {
122 expect(res
.body
).to
.be
.an('array')
123 expect(res
.body
.length
).to
.equal(0)
129 after(function (done
) {
130 process
.kill(-app
.pid
)
131 process
.kill(-webtorrent
.app
.pid
)
133 // Keep the logs if the test failed
135 utils
.flushTests(function () {