]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | |
2 | ||
3 | import 'mocha' | |
4 | import { expect } from 'chai' | |
5 | import { | |
6 | cleanupTests, | |
7 | createSingleServer, | |
8 | makeGetRequest, | |
9 | PeerTubeServer, | |
10 | PluginsCommand, | |
11 | setAccessTokensToServers | |
12 | } from '@shared/extra-utils' | |
13 | import { HttpStatusCode } from '@shared/models' | |
14 | ||
15 | describe('Test plugins module unloading', function () { | |
16 | let server: PeerTubeServer = null | |
17 | const requestPath = '/plugins/test-unloading/router/get' | |
18 | let value: string = null | |
19 | ||
20 | before(async function () { | |
21 | this.timeout(30000) | |
22 | ||
23 | server = await createSingleServer(1) | |
24 | await setAccessTokensToServers([ server ]) | |
25 | ||
26 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) | |
27 | }) | |
28 | ||
29 | it('Should return a numeric value', async function () { | |
30 | const res = await makeGetRequest({ | |
31 | url: server.url, | |
32 | path: requestPath, | |
33 | expectedStatus: HttpStatusCode.OK_200 | |
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, | |
44 | expectedStatus: HttpStatusCode.OK_200 | |
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 () { | |
51 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' }) | |
52 | ||
53 | await makeGetRequest({ | |
54 | url: server.url, | |
55 | path: requestPath, | |
56 | expectedStatus: HttpStatusCode.NOT_FOUND_404 | |
57 | }) | |
58 | }) | |
59 | ||
60 | it('Should return a different numeric value', async function () { | |
61 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) | |
62 | ||
63 | const res = await makeGetRequest({ | |
64 | url: server.url, | |
65 | path: requestPath, | |
66 | expectedStatus: HttpStatusCode.OK_200 | |
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 | }) |