diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/server/plugins.ts | 32 | ||||
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-native/main.js | 21 | ||||
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-native/package.json | 23 |
3 files changed, 76 insertions, 0 deletions
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts index 8aa34fb15..3ae99dc2e 100644 --- a/server/tests/api/server/plugins.ts +++ b/server/tests/api/server/plugins.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { pathExists, remove } from 'fs-extra' | ||
6 | import { join } from 'path' | ||
5 | import { testHelloWorldRegisteredSettings } from '@server/tests/shared' | 7 | import { testHelloWorldRegisteredSettings } from '@server/tests/shared' |
6 | import { wait } from '@shared/core-utils' | 8 | import { wait } from '@shared/core-utils' |
7 | import { HttpStatusCode, PluginType } from '@shared/models' | 9 | import { HttpStatusCode, PluginType } from '@shared/models' |
@@ -9,6 +11,7 @@ import { | |||
9 | cleanupTests, | 11 | cleanupTests, |
10 | createSingleServer, | 12 | createSingleServer, |
11 | killallServers, | 13 | killallServers, |
14 | makeGetRequest, | ||
12 | PeerTubeServer, | 15 | PeerTubeServer, |
13 | PluginsCommand, | 16 | PluginsCommand, |
14 | setAccessTokensToServers | 17 | setAccessTokensToServers |
@@ -349,6 +352,35 @@ describe('Test plugins', function () { | |||
349 | await check() | 352 | await check() |
350 | }) | 353 | }) |
351 | 354 | ||
355 | it('Should rebuild native modules on Node ABI change', async function () { | ||
356 | await command.install({ path: PluginsCommand.getPluginTestPath('-native') }) | ||
357 | |||
358 | await makeGetRequest({ | ||
359 | url: server.url, | ||
360 | path: '/plugins/test-native/router', | ||
361 | expectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
362 | }) | ||
363 | |||
364 | const query = `UPDATE "application" SET "nodeABIVersion" = 1` | ||
365 | await server.sql.updateQuery(query) | ||
366 | |||
367 | const baseNativeModule = server.servers.buildDirectory(join('plugins', 'node_modules', 'a-native-example')) | ||
368 | await remove(join(baseNativeModule, 'build')) | ||
369 | await remove(join(baseNativeModule, 'prebuilds')) | ||
370 | |||
371 | await server.kill() | ||
372 | await server.run() | ||
373 | |||
374 | await pathExists(join(baseNativeModule, 'build')) | ||
375 | await pathExists(join(baseNativeModule, 'prebuilds')) | ||
376 | |||
377 | await makeGetRequest({ | ||
378 | url: server.url, | ||
379 | path: '/plugins/test-native/router', | ||
380 | expectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
381 | }) | ||
382 | }) | ||
383 | |||
352 | after(async function () { | 384 | after(async function () { |
353 | await cleanupTests([ server ]) | 385 | await cleanupTests([ server ]) |
354 | }) | 386 | }) |
diff --git a/server/tests/fixtures/peertube-plugin-test-native/main.js b/server/tests/fixtures/peertube-plugin-test-native/main.js new file mode 100644 index 000000000..0390faea9 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-native/main.js | |||
@@ -0,0 +1,21 @@ | |||
1 | const print = require('a-native-example') | ||
2 | |||
3 | async function register ({ getRouter }) { | ||
4 | print('hello world') | ||
5 | |||
6 | const router = getRouter() | ||
7 | |||
8 | router.get('/', (req, res) => { | ||
9 | print('hello world') | ||
10 | res.sendStatus(204) | ||
11 | }) | ||
12 | } | ||
13 | |||
14 | async function unregister () { | ||
15 | return | ||
16 | } | ||
17 | |||
18 | module.exports = { | ||
19 | register, | ||
20 | unregister | ||
21 | } | ||
diff --git a/server/tests/fixtures/peertube-plugin-test-native/package.json b/server/tests/fixtures/peertube-plugin-test-native/package.json new file mode 100644 index 000000000..a6525720b --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-native/package.json | |||
@@ -0,0 +1,23 @@ | |||
1 | { | ||
2 | "name": "peertube-plugin-test-native", | ||
3 | "version": "0.0.1", | ||
4 | "description": "Plugin test-native", | ||
5 | "engine": { | ||
6 | "peertube": ">=4.3.0" | ||
7 | }, | ||
8 | "keywords": [ | ||
9 | "peertube", | ||
10 | "plugin" | ||
11 | ], | ||
12 | "homepage": "https://github.com/Chocobozzz/PeerTube", | ||
13 | "author": "Chocobozzz", | ||
14 | "bugs": "https://github.com/Chocobozzz/PeerTube/issues", | ||
15 | "library": "./main.js", | ||
16 | "staticDirs": {}, | ||
17 | "css": [], | ||
18 | "clientScripts": [], | ||
19 | "translations": {}, | ||
20 | "dependencies": { | ||
21 | "a-native-example": "^1.0.0" | ||
22 | } | ||
23 | } | ||