]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - tests/api/singlePod.js
4 var async
= require('async')
5 var chai
= require('chai')
6 var expect
= chai
.expect
8 var pathUtils
= require('path')
10 var webtorrent
= require(pathUtils
.join(__dirname
, '../../lib/webtorrent'))
11 webtorrent
.silent
= true
13 var utils
= require('./utils')
15 describe('Test a single pod', function () {
20 before(function (done
) {
25 utils
.flushTests(next
)
28 utils
.runServer(1, function (app1
, url1
) {
35 webtorrent
.create({ host: 'client', port: '1' }, next
)
40 it('Should not have videos', function (done
) {
41 utils
.getVideosList(url
, function (err
, res
) {
44 expect(res
.body
).to
.be
.an('array')
45 expect(res
.body
.length
).to
.equal(0)
51 it('Should upload the video', function (done
) {
53 utils
.uploadVideo(url
, 'my super name', 'my super description', 'video_short.webm', done
)
56 it('Should seed the uploaded video', function (done
) {
57 // Yes, this could be long
60 utils
.getVideosList(url
, function (err
, res
) {
63 expect(res
.body
).to
.be
.an('array')
64 expect(res
.body
.length
).to
.equal(1)
66 var video
= res
.body
[0]
67 expect(video
.name
).to
.equal('my super name')
68 expect(video
.description
).to
.equal('my super description')
69 expect(video
.podUrl
).to
.equal('http://localhost:9001')
70 expect(video
.magnetUri
).to
.exist
74 webtorrent
.add(video
.magnetUri
, function (torrent
) {
75 expect(torrent
.files
).to
.exist
76 expect(torrent
.files
.length
).to
.equal(1)
77 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
84 it('Should search the video', function (done
) {
85 utils
.searchVideo(url
, 'my', function (err
, res
) {
88 expect(res
.body
).to
.be
.an('array')
89 expect(res
.body
.length
).to
.equal(1)
91 var video
= res
.body
[0]
92 expect(video
.name
).to
.equal('my super name')
93 expect(video
.description
).to
.equal('my super description')
94 expect(video
.podUrl
).to
.equal('http://localhost:9001')
95 expect(video
.magnetUri
).to
.exist
101 it('Should not find a search', function (done
) {
102 utils
.searchVideo(url
, 'hello', function (err
, res
) {
105 expect(res
.body
).to
.be
.an('array')
106 expect(res
.body
.length
).to
.equal(0)
112 it('Should remove the video', function (done
) {
113 utils
.removeVideo(url
, video_id
, function (err
) {
116 fs
.readdir(pathUtils
.join(__dirname
, '../../test1/uploads/'), function (err
, files
) {
119 expect(files
.length
).to
.equal(0)
125 it('Should not have videos', function (done
) {
126 utils
.getVideosList(url
, function (err
, res
) {
129 expect(res
.body
).to
.be
.an('array')
130 expect(res
.body
.length
).to
.equal(0)
136 after(function (done
) {
137 process
.kill(-app
.pid
)
138 process
.kill(-webtorrent
.app
.pid
)
140 // Keep the logs if the test failed
142 utils
.flushTests(done
)