]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/plugins/plugin-unloading.ts
Shorter server command names
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / plugin-unloading.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import { expect } from 'chai'
5 import { HttpStatusCode } from '@shared/core-utils'
6 import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
7
8 describe('Test plugins module unloading', function () {
9 let server: ServerInfo = null
10 const requestPath = '/plugins/test-unloading/router/get'
11 let value: string = null
12
13 before(async function () {
14 this.timeout(30000)
15
16 server = await flushAndRunServer(1)
17 await setAccessTokensToServers([ server ])
18
19 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
20 })
21
22 it('Should return a numeric value', async function () {
23 const res = await makeGetRequest({
24 url: server.url,
25 path: requestPath,
26 statusCodeExpected: HttpStatusCode.OK_200
27 })
28
29 expect(res.body.message).to.match(/^\d+$/)
30 value = res.body.message
31 })
32
33 it('Should return the same value the second time', async function () {
34 const res = await makeGetRequest({
35 url: server.url,
36 path: requestPath,
37 statusCodeExpected: HttpStatusCode.OK_200
38 })
39
40 expect(res.body.message).to.be.equal(value)
41 })
42
43 it('Should uninstall the plugin and free the route', async function () {
44 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
45
46 await makeGetRequest({
47 url: server.url,
48 path: requestPath,
49 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
50 })
51 })
52
53 it('Should return a different numeric value', async function () {
54 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
55
56 const res = await makeGetRequest({
57 url: server.url,
58 path: requestPath,
59 statusCodeExpected: HttpStatusCode.OK_200
60 })
61
62 expect(res.body.message).to.match(/^\d+$/)
63 expect(res.body.message).to.be.not.equal(value)
64 })
65
66 after(async function () {
67 await cleanupTests([ server ])
68 })
69 })