diff options
Diffstat (limited to 'server/tests/plugins/plugin-unloading.ts')
-rw-r--r-- | server/tests/plugins/plugin-unloading.ts | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 74ca82e2f..6bf2fda9b 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts | |||
@@ -1,42 +1,36 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | ||
4 | import { | 5 | import { |
5 | cleanupTests, | 6 | cleanupTests, |
6 | flushAndRunServer, | 7 | createSingleServer, |
7 | getPluginTestPath, | ||
8 | makeGetRequest, | 8 | makeGetRequest, |
9 | installPlugin, | 9 | PeerTubeServer, |
10 | uninstallPlugin, | 10 | PluginsCommand, |
11 | ServerInfo, | ||
12 | setAccessTokensToServers | 11 | setAccessTokensToServers |
13 | } from '../../../shared/extra-utils' | 12 | } from '@shared/extra-utils' |
14 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '@shared/models' |
15 | import { expect } from 'chai' | ||
16 | 14 | ||
17 | describe('Test plugins module unloading', function () { | 15 | describe('Test plugins module unloading', function () { |
18 | let server: ServerInfo = null | 16 | let server: PeerTubeServer = null |
19 | const requestPath = '/plugins/test-unloading/router/get' | 17 | const requestPath = '/plugins/test-unloading/router/get' |
20 | let value: string = null | 18 | let value: string = null |
21 | 19 | ||
22 | before(async function () { | 20 | before(async function () { |
23 | this.timeout(30000) | 21 | this.timeout(30000) |
24 | 22 | ||
25 | server = await flushAndRunServer(1) | 23 | server = await createSingleServer(1) |
26 | await setAccessTokensToServers([ server ]) | 24 | await setAccessTokensToServers([ server ]) |
27 | 25 | ||
28 | await installPlugin({ | 26 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
29 | url: server.url, | ||
30 | accessToken: server.accessToken, | ||
31 | path: getPluginTestPath('-unloading') | ||
32 | }) | ||
33 | }) | 27 | }) |
34 | 28 | ||
35 | it('Should return a numeric value', async function () { | 29 | it('Should return a numeric value', async function () { |
36 | const res = await makeGetRequest({ | 30 | const res = await makeGetRequest({ |
37 | url: server.url, | 31 | url: server.url, |
38 | path: requestPath, | 32 | path: requestPath, |
39 | statusCodeExpected: HttpStatusCode.OK_200 | 33 | expectedStatus: HttpStatusCode.OK_200 |
40 | }) | 34 | }) |
41 | 35 | ||
42 | expect(res.body.message).to.match(/^\d+$/) | 36 | expect(res.body.message).to.match(/^\d+$/) |
@@ -47,36 +41,29 @@ describe('Test plugins module unloading', function () { | |||
47 | const res = await makeGetRequest({ | 41 | const res = await makeGetRequest({ |
48 | url: server.url, | 42 | url: server.url, |
49 | path: requestPath, | 43 | path: requestPath, |
50 | statusCodeExpected: HttpStatusCode.OK_200 | 44 | expectedStatus: HttpStatusCode.OK_200 |
51 | }) | 45 | }) |
52 | 46 | ||
53 | expect(res.body.message).to.be.equal(value) | 47 | expect(res.body.message).to.be.equal(value) |
54 | }) | 48 | }) |
55 | 49 | ||
56 | it('Should uninstall the plugin and free the route', async function () { | 50 | it('Should uninstall the plugin and free the route', async function () { |
57 | await uninstallPlugin({ | 51 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' }) |
58 | url: server.url, | ||
59 | accessToken: server.accessToken, | ||
60 | npmName: 'peertube-plugin-test-unloading' | ||
61 | }) | ||
62 | 52 | ||
63 | await makeGetRequest({ | 53 | await makeGetRequest({ |
64 | url: server.url, | 54 | url: server.url, |
65 | path: requestPath, | 55 | path: requestPath, |
66 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 56 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
67 | }) | 57 | }) |
68 | }) | 58 | }) |
69 | 59 | ||
70 | it('Should return a different numeric value', async function () { | 60 | it('Should return a different numeric value', async function () { |
71 | await installPlugin({ | 61 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) |
72 | url: server.url, | 62 | |
73 | accessToken: server.accessToken, | ||
74 | path: getPluginTestPath('-unloading') | ||
75 | }) | ||
76 | const res = await makeGetRequest({ | 63 | const res = await makeGetRequest({ |
77 | url: server.url, | 64 | url: server.url, |
78 | path: requestPath, | 65 | path: requestPath, |
79 | statusCodeExpected: HttpStatusCode.OK_200 | 66 | expectedStatus: HttpStatusCode.OK_200 |
80 | }) | 67 | }) |
81 | 68 | ||
82 | expect(res.body.message).to.match(/^\d+$/) | 69 | expect(res.body.message).to.match(/^\d+$/) |