]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - test/api/singlePod.js
4 var request
= require('supertest')
5 var chai
= require('chai')
7 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 () {
14 var path
= '/api/v1/videos'
19 before(function (done
) {
22 utils
.flushTests(function () {
23 utils
.runServer(1, function (app1
, url1
) {
27 webtorrent
.create({ host: 'client', port: '1' }, function () {
34 it('Should not have videos', function (done
) {
37 .set('Accept', 'application/json')
39 .expect('Content-Type', /json/)
40 .end(function (err
, res
) {
43 expect(res
.body
).to
.be
.an('array')
44 expect(res
.body
.length
).to
.equal(0)
50 it('Should upload the video', function (done
) {
55 .set('Accept', 'application/json')
56 .field('name', 'my super name')
57 .field('description', 'my super description')
58 .attach('input_video', __dirname
+ '/../fixtures/video_short.webm')
62 it('Should seed the uploaded video', function (done
) {
63 // Yes, this could be long
68 .set('Accept', 'application/json')
70 .expect('Content-Type', /json/)
71 .end(function (err
, res
) {
74 expect(res
.body
).to
.be
.an('array')
75 expect(res
.body
.length
).to
.equal(1)
77 var video
= res
.body
[0]
78 expect(video
.name
).to
.equal('my super name')
79 expect(video
.description
).to
.equal('my super description')
80 expect(video
.podUrl
).to
.equal('http://localhost:9001')
81 expect(video
.magnetUri
).to
.exist
85 webtorrent
.add(video
.magnetUri
, function (torrent
) {
86 expect(torrent
.files
).to
.exist
87 expect(torrent
.files
.length
).to
.equal(1)
88 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
95 it('Should remove the video', function (done
) {
97 .delete(path
+ '/' + video_id
)
98 .set('Accept', 'application/json')
100 .end(function (err
, res
) {
103 fs
.readdir(__dirname
+ '/../../test1/uploads/', function (err
, files
) {
106 expect(files
.length
).to
.equal(0)
112 it('Should not have videos', function (done
) {
115 .set('Accept', 'application/json')
117 .expect('Content-Type', /json/)
118 .end(function (err
, res
) {
121 expect(res
.body
).to
.be
.an('array')
122 expect(res
.body
.length
).to
.equal(0)
128 after(function (done
) {
129 process
.kill(-app
.pid
)
130 process
.kill(-webtorrent
.app
.pid
)
132 // Keep the logs if the test failed
134 utils
.flushTests(function () {