]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/plugin-unloading.ts
Fix tests
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / plugin-unloading.ts
index 74ca82e2f23f0ad878f55337a1c23c12cbbbfb0b..a94b836950b9f339c952b135d6994e5fa8e14ca3 100644 (file)
@@ -1,42 +1,36 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
+import { expect } from 'chai'
 import {
   cleanupTests,
-  flushAndRunServer,
-  getPluginTestPath,
+  createSingleServer,
   makeGetRequest,
-  installPlugin,
-  uninstallPlugin,
-  ServerInfo,
+  PeerTubeServer,
+  PluginsCommand,
   setAccessTokensToServers
-} from '../../../shared/extra-utils'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-import { expect } from 'chai'
+} from '@shared/server-commands'
+import { HttpStatusCode } from '@shared/models'
 
 describe('Test plugins module unloading', function () {
-  let server: ServerInfo = null
+  let server: PeerTubeServer = null
   const requestPath = '/plugins/test-unloading/router/get'
   let value: string = null
 
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
     await setAccessTokensToServers([ server ])
 
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      path: getPluginTestPath('-unloading')
-    })
+    await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
   })
 
   it('Should return a numeric value', async function () {
     const res = await makeGetRequest({
       url: server.url,
       path: requestPath,
-      statusCodeExpected: HttpStatusCode.OK_200
+      expectedStatus: HttpStatusCode.OK_200
     })
 
     expect(res.body.message).to.match(/^\d+$/)
@@ -47,36 +41,29 @@ describe('Test plugins module unloading', function () {
     const res = await makeGetRequest({
       url: server.url,
       path: requestPath,
-      statusCodeExpected: HttpStatusCode.OK_200
+      expectedStatus: HttpStatusCode.OK_200
     })
 
     expect(res.body.message).to.be.equal(value)
   })
 
   it('Should uninstall the plugin and free the route', async function () {
-    await uninstallPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      npmName: 'peertube-plugin-test-unloading'
-    })
+    await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
 
     await makeGetRequest({
       url: server.url,
       path: requestPath,
-      statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+      expectedStatus: HttpStatusCode.NOT_FOUND_404
     })
   })
 
   it('Should return a different numeric value', async function () {
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      path: getPluginTestPath('-unloading')
-    })
+    await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
+
     const res = await makeGetRequest({
       url: server.url,
       path: requestPath,
-      statusCodeExpected: HttpStatusCode.OK_200
+      expectedStatus: HttpStatusCode.OK_200
     })
 
     expect(res.body.message).to.match(/^\d+$/)