aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-22 10:55:28 +0200
committerChocobozzz <me@florianbigard.com>2021-04-22 10:55:28 +0200
commit302eba0d898e38dca14739486441c27c0be6c62f (patch)
tree280d18bfe2ad1b16248277371e609c31d6b3aaa4 /server/tests/fixtures
parent3e0e8d4afded28559b7c473061bbdc31ab542e1c (diff)
downloadPeerTube-302eba0d898e38dca14739486441c27c0be6c62f.tar.gz
PeerTube-302eba0d898e38dca14739486441c27c0be6c62f.tar.zst
PeerTube-302eba0d898e38dca14739486441c27c0be6c62f.zip
Add data directory for plugins and some helpers
Diffstat (limited to 'server/tests/fixtures')
-rw-r--r--server/tests/fixtures/peertube-plugin-test-four/main.js23
-rw-r--r--server/tests/fixtures/peertube-plugin-test-six/main.js18
2 files changed, 39 insertions, 2 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js
index ea0599997..6930ac511 100644
--- a/server/tests/fixtures/peertube-plugin-test-four/main.js
+++ b/server/tests/fixtures/peertube-plugin-test-four/main.js
@@ -77,10 +77,31 @@ async function register ({
77 }) 77 })
78 78
79 router.get('/static-route', async (req, res) => { 79 router.get('/static-route', async (req, res) => {
80 const staticRoute = await peertubeHelpers.plugin.getBaseStaticRoute() 80 const staticRoute = peertubeHelpers.plugin.getBaseStaticRoute()
81 81
82 return res.json({ staticRoute }) 82 return res.json({ staticRoute })
83 }) 83 })
84
85 router.get('/router-route', async (req, res) => {
86 const routerRoute = peertubeHelpers.plugin.getBaseRouterRoute()
87
88 return res.json({ routerRoute })
89 })
90
91 router.get('/user', async (req, res) => {
92 const user = peertubeHelpers.user.getAuthUser(res)
93
94 const isAdmin = user.role === 0
95 const isModerator = user.role === 1
96 const isUser = user.role === 2
97
98 return res.json({
99 username: user.username,
100 isAdmin,
101 isModerator,
102 isUser
103 })
104 })
84 } 105 }
85 106
86} 107}
diff --git a/server/tests/fixtures/peertube-plugin-test-six/main.js b/server/tests/fixtures/peertube-plugin-test-six/main.js
index bb9aaffa7..858bdb2df 100644
--- a/server/tests/fixtures/peertube-plugin-test-six/main.js
+++ b/server/tests/fixtures/peertube-plugin-test-six/main.js
@@ -1,6 +1,10 @@
1const fs = require('fs')
2const path = require('path')
3
1async function register ({ 4async function register ({
2 storageManager, 5 storageManager,
3 peertubeHelpers 6 peertubeHelpers,
7 getRouter
4}) { 8}) {
5 const { logger } = peertubeHelpers 9 const { logger } = peertubeHelpers
6 10
@@ -11,6 +15,18 @@ async function register ({
11 const result = await storageManager.getData('superkey') 15 const result = await storageManager.getData('superkey')
12 logger.info('superkey stored value is %s', result.value) 16 logger.info('superkey stored value is %s', result.value)
13 } 17 }
18
19 {
20 getRouter().get('/create-file', async (req, res) => {
21 const basePath = peertubeHelpers.plugin.getDataDirectoryPath()
22
23 fs.writeFile(path.join(basePath, 'Aladdin.txt'), 'Prince Ali', function (err) {
24 if (err) return res.sendStatus(500)
25
26 res.sendStatus(200)
27 })
28 })
29 }
14} 30}
15 31
16async function unregister () { 32async function unregister () {