]>
Commit | Line | Data |
---|---|---|
41137192 JL |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
41137192 | 4 | import { expect } from 'chai' |
ae2abfd3 C |
5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' | |
41137192 JL |
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 | ||
ae2abfd3 | 19 | await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
41137192 JL |
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 () { | |
ae2abfd3 | 44 | await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' }) |
41137192 JL |
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 () { | |
ae2abfd3 C |
54 | await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
55 | ||
41137192 JL |
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 | }) |