From 97b65ce58aaacbbfec2291f18fb95a9da9eb5263 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 4 May 2020 09:44:00 +0200 Subject: Fix plugin storeData --- .../fixtures/peertube-plugin-test-six/main.js | 25 ++++++++++++++++++ .../fixtures/peertube-plugin-test-six/package.json | 20 +++++++++++++++ server/tests/plugins/index.ts | 1 + server/tests/plugins/plugin-storage.ts | 30 ++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 server/tests/fixtures/peertube-plugin-test-six/main.js create mode 100644 server/tests/fixtures/peertube-plugin-test-six/package.json create mode 100644 server/tests/plugins/plugin-storage.ts (limited to 'server/tests') diff --git a/server/tests/fixtures/peertube-plugin-test-six/main.js b/server/tests/fixtures/peertube-plugin-test-six/main.js new file mode 100644 index 000000000..bb9aaffa7 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-six/main.js @@ -0,0 +1,25 @@ +async function register ({ + storageManager, + peertubeHelpers +}) { + const { logger } = peertubeHelpers + + { + await storageManager.storeData('superkey', { value: 'toto' }) + await storageManager.storeData('anotherkey', { value: 'toto2' }) + + const result = await storageManager.getData('superkey') + logger.info('superkey stored value is %s', result.value) + } +} + +async function unregister () { + return +} + +module.exports = { + register, + unregister +} + +// ########################################################################### diff --git a/server/tests/fixtures/peertube-plugin-test-six/package.json b/server/tests/fixtures/peertube-plugin-test-six/package.json new file mode 100644 index 000000000..8c97826b0 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test-six/package.json @@ -0,0 +1,20 @@ +{ + "name": "peertube-plugin-test-six", + "version": "0.0.1", + "description": "Plugin test 6", + "engine": { + "peertube": ">=1.3.0" + }, + "keywords": [ + "peertube", + "plugin" + ], + "homepage": "https://github.com/Chocobozzz/PeerTube", + "author": "Chocobozzz", + "bugs": "https://github.com/Chocobozzz/PeerTube/issues", + "library": "./main.js", + "staticDirs": {}, + "css": [], + "clientScripts": [], + "translations": {} +} diff --git a/server/tests/plugins/index.ts b/server/tests/plugins/index.ts index d2bd69131..39c4c958a 100644 --- a/server/tests/plugins/index.ts +++ b/server/tests/plugins/index.ts @@ -6,3 +6,4 @@ import './translations' import './video-constants' import './plugin-helpers' import './plugin-router' +import './plugin-storage' diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts new file mode 100644 index 000000000..356692eb9 --- /dev/null +++ b/server/tests/plugins/plugin-storage.ts @@ -0,0 +1,30 @@ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ + +import 'mocha' +import { getPluginTestPath, installPlugin, setAccessTokensToServers } from '../../../shared/extra-utils' +import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' + +describe('Test plugin storage', function () { + let server: ServerInfo + + before(async function () { + this.timeout(30000) + + server = await flushAndRunServer(1) + await setAccessTokensToServers([ server ]) + + await installPlugin({ + url: server.url, + accessToken: server.accessToken, + path: getPluginTestPath('-six') + }) + }) + + it('Should correctly store a subkey', async function () { + await waitUntilLog(server, 'superkey stored value is toto') + }) + + after(async function () { + await cleanupTests([ server ]) + }) +}) -- cgit v1.2.3