]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - test/api/utils.js
Tests refractoring
[github/Chocobozzz/PeerTube.git] / test / api / utils.js
index b00890539e6d329968b41c521636bb15af6169e6..afb0abb33cc62d3e54772f8403af8a1975899b4e 100644 (file)
@@ -6,10 +6,23 @@
   var fork = child_process.fork
   var request = require('supertest')
 
+  module.exports = {
+    flushTests: flushTests,
+    getFriendsList: getFriendsList,
+    getVideosList: getVideosList,
+    makeFriends: makeFriends,
+    quitFriends: quitFriends,
+    removeVideo: removeVideo,
+    flushAndRunMultipleServers: flushAndRunMultipleServers,
+    runServer: runServer,
+    searchVideo: searchVideo,
+    uploadVideo: uploadVideo
+  }
+
+  // ---------------------- Export functions --------------------
+
   function flushTests (callback) {
-    exec(__dirname + '/../../scripts/clean_test.sh', function () {
-      callback()
-    })
+    exec(__dirname + '/../../scripts/clean_test.sh', callback)
   }
 
   function getFriendsList (url, end) {
@@ -51,9 +64,7 @@
         if (err) throw err
 
         // Wait for the request between pods
-        setTimeout(function () {
-          callback()
-        }, 1000)
+        setTimeout(callback, 1000)
       })
   }
 
         if (err) throw err
 
         // Wait for the request between pods
-        setTimeout(function () {
-          callback()
-        }, 1000)
+        setTimeout(callback, 1000)
       })
   }
 
-  function uploadVideo (url, name, description, fixture, end) {
-    var path = '/api/v1/videos'
-
-    request(url)
-      .post(path)
-      .set('Accept', 'application/json')
-      .field('name', name)
-      .field('description', description)
-      .attach('input_video', __dirname + '/fixtures/' + fixture)
-      .expect(201)
-      .end(end)
-  }
-
   function removeVideo (url, id, end) {
     var path = '/api/v1/videos'
 
@@ -98,7 +94,7 @@
       .end(end)
   }
 
-  function runMultipleServers (total_servers, serversRun) {
+  function flushAndRunMultipleServers (total_servers, serversRun) {
     var apps = []
     var urls = []
     var i = 0
       .end(end)
   }
 
-  module.exports = {
-    flushTests: flushTests,
-    getFriendsList: getFriendsList,
-    getVideosList: getVideosList,
-    makeFriends: makeFriends,
-    quitFriends: quitFriends,
-    removeVideo: removeVideo,
-    runMultipleServers: runMultipleServers,
-    runServer: runServer,
-    searchVideo: searchVideo,
-    uploadVideo: uploadVideo
+  function uploadVideo (url, name, description, fixture, end) {
+    var path = '/api/v1/videos'
+
+    request(url)
+      .post(path)
+      .set('Accept', 'application/json')
+      .field('name', name)
+      .field('description', description)
+      .attach('input_video', __dirname + '/fixtures/' + fixture)
+      .expect(201)
+      .end(end)
   }
 })()