aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/fixtures/peertube-plugin-test-six/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/fixtures/peertube-plugin-test-six/main.js')
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-six/main.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/tests/fixtures/peertube-plugin-test-six/main.js b/packages/tests/fixtures/peertube-plugin-test-six/main.js
new file mode 100644
index 000000000..243b041e7
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-six/main.js
@@ -0,0 +1,46 @@
1const fs = require('fs')
2const path = require('path')
3
4async function register ({
5 storageManager,
6 peertubeHelpers,
7 getRouter
8}) {
9 const { logger } = peertubeHelpers
10
11 {
12 await storageManager.storeData('superkey', { value: 'toto' })
13 await storageManager.storeData('anotherkey', { value: 'toto2' })
14 await storageManager.storeData('storedArrayKey', ['toto', 'toto2'])
15
16 const result = await storageManager.getData('superkey')
17 logger.info('superkey stored value is %s', result.value)
18
19 const storedArrayValue = await storageManager.getData('storedArrayKey')
20 logger.info('storedArrayKey isArray is %s', Array.isArray(storedArrayValue) ? 'true' : 'false')
21 logger.info('storedArrayKey stored value is %s', storedArrayValue.join(', '))
22 }
23
24 {
25 getRouter().get('/create-file', async (req, res) => {
26 const basePath = peertubeHelpers.plugin.getDataDirectoryPath()
27
28 fs.writeFile(path.join(basePath, 'Aladdin.txt'), 'Prince Ali', function (err) {
29 if (err) return res.sendStatus(500)
30
31 res.sendStatus(200)
32 })
33 })
34 }
35}
36
37async function unregister () {
38 return
39}
40
41module.exports = {
42 register,
43 unregister
44}
45
46// ###########################################################################