]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/tracker.ts
Remove tmp file on image processing error
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / tracker.ts
index 5d61c1558aa6015008724dab456d11fda7648084..41803aef133d61893458bdbcbdd6823ad80aa685 100644 (file)
@@ -1,10 +1,9 @@
 /* tslint:disable:no-unused-expression */
 
 import * as magnetUtil from 'magnet-uri'
-import * as chai from 'chai'
 import 'mocha'
-import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../utils'
-import { flushTests, setAccessTokensToServers } from '../../utils/index'
+import { getVideo, killallServers, reRunServer, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils'
+import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index'
 import { VideoDetails } from '../../../../shared/models/videos'
 import * as WebTorrent from 'webtorrent'
 
@@ -35,7 +34,7 @@ describe('Test tracker', function () {
     }
   })
 
-  it('Should return an error when adding an incorrect infohash', done => {
+  it('Should return an error when adding an incorrect infohash', function (done) {
     this.timeout(10000)
     const webtorrent = new WebTorrent()
 
@@ -50,7 +49,7 @@ describe('Test tracker', function () {
     torrent.on('done', () => done(new Error('No error on infohash')))
   })
 
-  it('Should succeed with the correct infohash', done => {
+  it('Should succeed with the correct infohash', function (done) {
     this.timeout(10000)
     const webtorrent = new WebTorrent()
 
@@ -65,6 +64,26 @@ describe('Test tracker', function () {
     torrent.on('done', done)
   })
 
+  it('Should disable the tracker', function (done) {
+    this.timeout(20000)
+
+    killallServers([ server ])
+    reRunServer(server, { tracker: { enabled: false } })
+      .then(() => {
+        const webtorrent = new WebTorrent()
+
+        const torrent = webtorrent.add(goodMagnet)
+
+        torrent.on('error', done)
+        torrent.on('warning', warn => {
+          const message = typeof warn === 'string' ? warn : warn.message
+          if (message.indexOf('disabled ') !== -1) return done()
+        })
+
+        torrent.on('done', () => done(new Error('Tracker is enabled')))
+      })
+  })
+
   after(async function () {
     killallServers([ server ])
   })