]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - test/api/utils.js
Finalise the join in a network and add the ability to quit it
[github/Chocobozzz/PeerTube.git] / test / api / utils.js
index 8d059b01cd0fd51bef2327bc715ae83025dcb9f4..b00890539e6d329968b41c521636bb15af6169e6 100644 (file)
       .end(end)
   }
 
-  function makeFriend (url, callback) {
+  function makeFriends (url, expected_status, callback) {
+    if (!callback) {
+      callback = expected_status
+      expected_status = 204
+    }
+
     var path = '/api/v1/pods/makefriends'
 
+    // The first pod make friend with the third
+    request(url)
+      .get(path)
+      .set('Accept', 'application/json')
+      .expect(expected_status)
+      .end(function (err, res) {
+        if (err) throw err
+
+        // Wait for the request between pods
+        setTimeout(function () {
+          callback()
+        }, 1000)
+      })
+  }
+
+  function quitFriends (url, callback) {
+    var path = '/api/v1/pods/quitfriends'
+
     // The first pod make friend with the third
     request(url)
       .get(path)
     flushTests: flushTests,
     getFriendsList: getFriendsList,
     getVideosList: getVideosList,
-    makeFriend: makeFriend,
+    makeFriends: makeFriends,
+    quitFriends: quitFriends,
     removeVideo: removeVideo,
     runMultipleServers: runMultipleServers,
     runServer: runServer,