]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/logs.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / logs.ts
index 9bc6ac2440d1475a22a8195d34baf775c3298c1b..dac1e6b98d2cd777ec5314436bc733b2e9f1680e 100644 (file)
@@ -1,17 +1,17 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 
 import {
+  cleanupTests,
   createUser,
-  flushTests,
-  killallServers,
-  runServer,
+  flushAndRunServer,
   ServerInfo,
   setAccessTokensToServers,
   userLogin
-} from '../../../../shared/utils'
-import { makeGetRequest } from '../../../../shared/utils/requests/requests'
+} from '../../../../shared/extra-utils'
+import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 describe('Test logs API validators', function () {
   const path = '/api/v1/server/logs'
@@ -23,9 +23,7 @@ describe('Test logs API validators', function () {
   before(async function () {
     this.timeout(120000)
 
-    await flushTests()
-
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
 
     await setAccessTokensToServers([ server ])
 
@@ -43,7 +41,7 @@ describe('Test logs API validators', function () {
       await makeGetRequest({
         url: server.url,
         path,
-        statusCodeExpected: 401
+        statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
       })
     })
 
@@ -52,7 +50,7 @@ describe('Test logs API validators', function () {
         url: server.url,
         path,
         token: userAccessToken,
-        statusCodeExpected: 403
+        statusCodeExpected: HttpStatusCode.FORBIDDEN_403
       })
     })
 
@@ -61,7 +59,7 @@ describe('Test logs API validators', function () {
         url: server.url,
         path,
         token: server.accessToken,
-        statusCodeExpected: 400
+        statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
       })
     })
 
@@ -71,7 +69,7 @@ describe('Test logs API validators', function () {
         path,
         token: server.accessToken,
         query: { startDate: 'toto' },
-        statusCodeExpected: 400
+        statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
       })
     })
 
@@ -81,7 +79,7 @@ describe('Test logs API validators', function () {
         path,
         token: server.accessToken,
         query: { startDate: new Date().toISOString(), endDate: 'toto' },
-        statusCodeExpected: 400
+        statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
       })
     })
 
@@ -91,7 +89,7 @@ describe('Test logs API validators', function () {
         path,
         token: server.accessToken,
         query: { startDate: new Date().toISOString(), level: 'toto' },
-        statusCodeExpected: 400
+        statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
       })
     })
 
@@ -101,17 +99,12 @@ describe('Test logs API validators', function () {
         path,
         token: server.accessToken,
         query: { startDate: new Date().toISOString() },
-        statusCodeExpected: 200
+        statusCodeExpected: HttpStatusCode.OK_200
       })
     })
   })
 
   after(async function () {
-    killallServers([ server ])
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests([ server ])
   })
 })