]>
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' |
254d3579 C |
5 | import { |
6 | cleanupTests, | |
7 | createSingleServer, | |
8 | makeGetRequest, | |
9 | PeerTubeServer, | |
10 | PluginsCommand, | |
11 | setAccessTokensToServers | |
12 | } from '@shared/extra-utils' | |
4c7e60bc | 13 | import { HttpStatusCode } from '@shared/models' |
41137192 JL |
14 | |
15 | describe('Test plugins module unloading', function () { | |
254d3579 | 16 | let server: PeerTubeServer = null |
41137192 JL |
17 | const requestPath = '/plugins/test-unloading/router/get' |
18 | let value: string = null | |
19 | ||
20 | before(async function () { | |
21 | this.timeout(30000) | |
22 | ||
254d3579 | 23 | server = await createSingleServer(1) |
41137192 JL |
24 | await setAccessTokensToServers([ server ]) |
25 | ||
89d241a7 | 26 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
41137192 JL |
27 | }) |
28 | ||
29 | it('Should return a numeric value', async function () { | |
30 | const res = await makeGetRequest({ | |
31 | url: server.url, | |
32 | path: requestPath, | |
c0e8b12e | 33 | expectedStatus: HttpStatusCode.OK_200 |
41137192 JL |
34 | }) |
35 | ||
36 | expect(res.body.message).to.match(/^\d+$/) | |
37 | value = res.body.message | |
38 | }) | |
39 | ||
40 | it('Should return the same value the second time', async function () { | |
41 | const res = await makeGetRequest({ | |
42 | url: server.url, | |
43 | path: requestPath, | |
c0e8b12e | 44 | expectedStatus: HttpStatusCode.OK_200 |
41137192 JL |
45 | }) |
46 | ||
47 | expect(res.body.message).to.be.equal(value) | |
48 | }) | |
49 | ||
50 | it('Should uninstall the plugin and free the route', async function () { | |
89d241a7 | 51 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' }) |
41137192 JL |
52 | |
53 | await makeGetRequest({ | |
54 | url: server.url, | |
55 | path: requestPath, | |
c0e8b12e | 56 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
41137192 JL |
57 | }) |
58 | }) | |
59 | ||
60 | it('Should return a different numeric value', async function () { | |
89d241a7 | 61 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
ae2abfd3 | 62 | |
41137192 JL |
63 | const res = await makeGetRequest({ |
64 | url: server.url, | |
65 | path: requestPath, | |
c0e8b12e | 66 | expectedStatus: HttpStatusCode.OK_200 |
41137192 JL |
67 | }) |
68 | ||
69 | expect(res.body.message).to.match(/^\d+$/) | |
70 | expect(res.body.message).to.be.not.equal(value) | |
71 | }) | |
72 | ||
73 | after(async function () { | |
74 | await cleanupTests([ server ]) | |
75 | }) | |
76 | }) |