]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - test/api/singlePod.js
59a617970924896147dbe6cf89ad14ae841538d0
4 var request
= require('supertest')
5 var chai
= require('chai')
6 var expect
= chai
.expect
7 var webtorrent
= require(__dirname
+ '/../../src/webTorrentNode')
8 webtorrent
.silent
= true
10 var utils
= require('../utils')
12 describe('Test a single pod', function () {
13 var path
= '/api/videos'
18 before(function (done
) {
21 utils
.flushTests(function () {
22 utils
.runServer(1, function (app1
, url1
) {
26 webtorrent
.create(function () {
33 it('Should not have videos', function (done
) {
36 .set('Accept', 'application/json')
38 .expect('Content-Type', /json/)
39 .end(function (err
, res
) {
42 expect(res
.body
).to
.be
.an('array')
43 expect(res
.body
.length
).to
.equal(0)
49 it('Should upload the video', function (done
) {
54 .set('Accept', 'application/json')
55 .field('name', 'my super name')
56 .field('description', 'my super description')
57 .attach('input_video', __dirname
+ '/../fixtures/video_short.webm')
61 it('Should seed the uploaded video', function (done
) {
62 // Yes, this could be long
67 .set('Accept', 'application/json')
69 .expect('Content-Type', /json/)
70 .end(function (err
, res
) {
73 expect(res
.body
).to
.be
.an('array')
74 expect(res
.body
.length
).to
.equal(1)
76 var video
= res
.body
[0]
77 expect(video
.name
).to
.equal('my super name')
78 expect(video
.description
).to
.equal('my super description')
79 expect(video
.podUrl
).to
.equal('http://localhost:9001')
80 expect(video
.magnetUri
).to
.exist
84 webtorrent
.add(video
.magnetUri
, function (torrent
) {
85 expect(torrent
.files
).to
.exist
86 expect(torrent
.files
.length
).to
.equal(1)
87 expect(torrent
.files
[0].path
).to
.exist
.and
.to
.not
.equal('')
94 it('Should remove the video', function (done
) {
96 .delete(path
+ '/' + video_id
)
97 .set('Accept', 'application/json')
99 .end(function (err
, res
) {
105 it('Should not have videos', function (done
) {
108 .set('Accept', 'application/json')
110 .expect('Content-Type', /json/)
111 .end(function (err
, res
) {
114 expect(res
.body
).to
.be
.an('array')
115 expect(res
.body
.length
).to
.equal(0)
121 after(function (done
) {
122 process
.kill(-app
.pid
)
123 process
.kill(-webtorrent
.app
.pid
)
125 // Keep the logs if the test failed
127 utils
.flushTests(function () {