]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/user-subscriptions.ts
Filter on follows actor types in about page
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / user-subscriptions.ts
index d33b3bca6374a8a414aed35f3d6b2c3a085ab34a..fa36c40780c7be91b9e0b663907107ab30a4d766 100644 (file)
@@ -3,13 +3,12 @@
 import 'mocha'
 
 import {
+  cleanupTests,
   createUser,
-  flushTests,
-  killallServers,
+  flushAndRunServer,
   makeDeleteRequest,
   makeGetRequest,
   makePostBodyRequest,
-  runServer,
   ServerInfo,
   setAccessTokensToServers,
   userLogin
@@ -32,9 +31,7 @@ describe('Test user subscriptions API validators', function () {
   before(async function () {
     this.timeout(30000)
 
-    await flushTests()
-
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
 
     await setAccessTokensToServers([ server ])
 
@@ -115,7 +112,7 @@ describe('Test user subscriptions API validators', function () {
       await makePostBodyRequest({
         url: server.url,
         path,
-        fields: { uri: 'user1_channel@localhost:9001' },
+        fields: { uri: 'user1_channel@localhost:' + server.port },
         statusCodeExpected: 401
       })
     })
@@ -153,7 +150,7 @@ describe('Test user subscriptions API validators', function () {
         url: server.url,
         path,
         token: server.accessToken,
-        fields: { uri: 'user1_channel@localhost:9001' },
+        fields: { uri: 'user1_channel@localhost:' + server.port },
         statusCodeExpected: 204
       })
 
@@ -165,7 +162,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should fail with a non authenticated user', async function () {
       await makeGetRequest({
         url: server.url,
-        path: path + '/user1_channel@localhost:9001',
+        path: path + '/user1_channel@localhost:' + server.port,
         statusCodeExpected: 401
       })
     })
@@ -196,7 +193,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should fail with an unknown subscription', async function () {
       await makeGetRequest({
         url: server.url,
-        path: path + '/root1@localhost:9001',
+        path: path + '/root1@localhost:' + server.port,
         token: server.accessToken,
         statusCodeExpected: 404
       })
@@ -205,7 +202,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should succeed with the correct parameters', async function () {
       await makeGetRequest({
         url: server.url,
-        path: path + '/user1_channel@localhost:9001',
+        path: path + '/user1_channel@localhost:' + server.port,
         token: server.accessToken,
         statusCodeExpected: 200
       })
@@ -245,7 +242,7 @@ describe('Test user subscriptions API validators', function () {
       await makeGetRequest({
         url: server.url,
         path: existPath,
-        query: { 'uris[]': 'coucou@localhost:9001' },
+        query: { 'uris[]': 'coucou@localhost:' + server.port },
         token: server.accessToken,
         statusCodeExpected: 200
       })
@@ -256,7 +253,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should fail with a non authenticated user', async function () {
       await makeDeleteRequest({
         url: server.url,
-        path: path + '/user1_channel@localhost:9001',
+        path: path + '/user1_channel@localhost:' + server.port,
         statusCodeExpected: 401
       })
     })
@@ -287,7 +284,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should fail with an unknown subscription', async function () {
       await makeDeleteRequest({
         url: server.url,
-        path: path + '/root1@localhost:9001',
+        path: path + '/root1@localhost:' + server.port,
         token: server.accessToken,
         statusCodeExpected: 404
       })
@@ -296,7 +293,7 @@ describe('Test user subscriptions API validators', function () {
     it('Should succeed with the correct parameters', async function () {
       await makeDeleteRequest({
         url: server.url,
-        path: path + '/user1_channel@localhost:9001',
+        path: path + '/user1_channel@localhost:' + server.port,
         token: server.accessToken,
         statusCodeExpected: 204
       })
@@ -304,11 +301,6 @@ describe('Test user subscriptions API validators', function () {
   })
 
   after(async function () {
-    killallServers([ server ])
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests([ server ])
   })
 })