]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/single-pod.js
Server: adapt tests to host
[github/Chocobozzz/PeerTube.git] / server / tests / api / single-pod.js
index bdaaee46c9c439e02aaae807bcacb28f6e549a7f..65d1a7a65187ec64e5521fdc17c2014fad95dd56 100644 (file)
@@ -7,13 +7,12 @@ const fs = require('fs')
 const keyBy = require('lodash/keyBy')
 const pathUtils = require('path')
 const series = require('async/series')
+const webtorrent = new (require('webtorrent'))()
 
 const loginUtils = require('../utils/login')
 const miscsUtils = require('../utils/miscs')
 const serversUtils = require('../utils/servers')
 const videosUtils = require('../utils/videos')
-const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
-webtorrent.silent = true
 
 describe('Test a single pod', function () {
   let server = null
@@ -39,9 +38,6 @@ describe('Test a single pod', function () {
           server.accessToken = token
           next()
         })
-      },
-      function (next) {
-        webtorrent.create({ host: 'client', port: '1' }, next)
       }
     ], done)
   })
@@ -81,7 +77,7 @@ describe('Test a single pod', function () {
       const video = res.body.data[0]
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
-      expect(video.podUrl).to.equal('localhost:9001')
+      expect(video.podHost).to.equal('localhost:9001')
       expect(video.magnetUri).to.exist
       expect(video.author).to.equal('root')
       expect(video.isLocal).to.be.true
@@ -115,7 +111,7 @@ describe('Test a single pod', function () {
       const video = res.body
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
-      expect(video.podUrl).to.equal('localhost:9001')
+      expect(video.podHost).to.equal('localhost:9001')
       expect(video.magnetUri).to.exist
       expect(video.author).to.equal('root')
       expect(video.isLocal).to.be.true
@@ -142,7 +138,7 @@ describe('Test a single pod', function () {
       const video = res.body.data[0]
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
-      expect(video.podUrl).to.equal('localhost:9001')
+      expect(video.podHost).to.equal('localhost:9001')
       expect(video.author).to.equal('root')
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
@@ -157,8 +153,8 @@ describe('Test a single pod', function () {
     })
   })
 
-  it('Should search the video by podUrl', function (done) {
-    videosUtils.searchVideo(server.url, '9001', 'podUrl', function (err, res) {
+  it('Should search the video by podHost', function (done) {
+    videosUtils.searchVideo(server.url, '9001', 'podHost', function (err, res) {
       if (err) throw err
 
       expect(res.body.total).to.equal(1)
@@ -168,7 +164,7 @@ describe('Test a single pod', function () {
       const video = res.body.data[0]
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
-      expect(video.podUrl).to.equal('localhost:9001')
+      expect(video.podHost).to.equal('localhost:9001')
       expect(video.author).to.equal('root')
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
@@ -194,7 +190,7 @@ describe('Test a single pod', function () {
       const video = res.body.data[0]
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
-      expect(video.podUrl).to.equal('localhost:9001')
+      expect(video.podHost).to.equal('localhost:9001')
       expect(video.author).to.equal('root')
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
@@ -249,11 +245,18 @@ describe('Test a single pod', function () {
     videosUtils.removeVideo(server.url, server.accessToken, videoId, function (err) {
       if (err) throw err
 
-      fs.readdir(pathUtils.join(__dirname, '../../../test1/uploads/'), function (err, files) {
+      fs.readdir(pathUtils.join(__dirname, '../../../test1/videos/'), function (err, files) {
         if (err) throw err
 
         expect(files.length).to.equal(0)
-        done()
+
+        fs.readdir(pathUtils.join(__dirname, '../../../test1/thumbnails/'), function (err, files) {
+          if (err) throw err
+
+          expect(files.length).to.equal(0)
+
+          done()
+        })
       })
     })
   })
@@ -422,7 +425,7 @@ describe('Test a single pod', function () {
   })
 
   it('Should search all the 9001 port videos', function (done) {
-    videosUtils.searchVideoWithPagination(server.url, '9001', 'podUrl', 0, 15, function (err, res) {
+    videosUtils.searchVideoWithPagination(server.url, '9001', 'podHost', 0, 15, function (err, res) {
       if (err) throw err
 
       const videos = res.body.data
@@ -434,7 +437,7 @@ describe('Test a single pod', function () {
   })
 
   it('Should search all the localhost videos', function (done) {
-    videosUtils.searchVideoWithPagination(server.url, 'localhost', 'podUrl', 0, 15, function (err, res) {
+    videosUtils.searchVideoWithPagination(server.url, 'localhost', 'podHost', 0, 15, function (err, res) {
       if (err) throw err
 
       const videos = res.body.data
@@ -496,7 +499,6 @@ describe('Test a single pod', function () {
 
   after(function (done) {
     process.kill(-server.app.pid)
-    process.kill(-webtorrent.app.pid)
 
     // Keep the logs if the test failed
     if (this.ok) {