aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/plugin-storage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins/plugin-storage.ts')
-rw-r--r--server/tests/plugins/plugin-storage.ts45
1 files changed, 16 insertions, 29 deletions
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 3c46b2585..e20c36dba 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -4,37 +4,32 @@ import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { pathExists, readdir, readFile } from 'fs-extra' 5import { pathExists, readdir, readFile } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils'
8import { 7import {
9 buildServerDirectory, 8 cleanupTests,
10 getPluginTestPath, 9 createSingleServer,
11 installPlugin,
12 makeGetRequest, 10 makeGetRequest,
13 setAccessTokensToServers, 11 PeerTubeServer,
14 uninstallPlugin 12 PluginsCommand,
15} from '../../../shared/extra-utils' 13 setAccessTokensToServers
16import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' 14} from '@shared/extra-utils'
15import { HttpStatusCode } from '@shared/models'
17 16
18describe('Test plugin storage', function () { 17describe('Test plugin storage', function () {
19 let server: ServerInfo 18 let server: PeerTubeServer
20 19
21 before(async function () { 20 before(async function () {
22 this.timeout(30000) 21 this.timeout(30000)
23 22
24 server = await flushAndRunServer(1) 23 server = await createSingleServer(1)
25 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
26 25
27 await installPlugin({ 26 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
28 url: server.url,
29 accessToken: server.accessToken,
30 path: getPluginTestPath('-six')
31 })
32 }) 27 })
33 28
34 describe('DB storage', function () { 29 describe('DB storage', function () {
35 30
36 it('Should correctly store a subkey', async function () { 31 it('Should correctly store a subkey', async function () {
37 await waitUntilLog(server, 'superkey stored value is toto') 32 await server.servers.waitUntilLog('superkey stored value is toto')
38 }) 33 })
39 }) 34 })
40 35
@@ -50,12 +45,12 @@ describe('Test plugin storage', function () {
50 } 45 }
51 46
52 before(function () { 47 before(function () {
53 dataPath = buildServerDirectory(server, 'plugins/data') 48 dataPath = server.servers.buildDirectory('plugins/data')
54 pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 49 pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
55 }) 50 })
56 51
57 it('Should have created the directory on install', async function () { 52 it('Should have created the directory on install', async function () {
58 const dataPath = buildServerDirectory(server, 'plugins/data') 53 const dataPath = server.servers.buildDirectory('plugins/data')
59 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 54 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
60 55
61 expect(await pathExists(dataPath)).to.be.true 56 expect(await pathExists(dataPath)).to.be.true
@@ -68,7 +63,7 @@ describe('Test plugin storage', function () {
68 url: server.url, 63 url: server.url,
69 token: server.accessToken, 64 token: server.accessToken,
70 path: '/plugins/test-six/router/create-file', 65 path: '/plugins/test-six/router/create-file',
71 statusCodeExpected: HttpStatusCode.OK_200 66 expectedStatus: HttpStatusCode.OK_200
72 }) 67 })
73 68
74 const content = await getFileContent() 69 const content = await getFileContent()
@@ -76,22 +71,14 @@ describe('Test plugin storage', function () {
76 }) 71 })
77 72
78 it('Should still have the file after an uninstallation', async function () { 73 it('Should still have the file after an uninstallation', async function () {
79 await uninstallPlugin({ 74 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-six' })
80 url: server.url,
81 accessToken: server.accessToken,
82 npmName: 'peertube-plugin-test-six'
83 })
84 75
85 const content = await getFileContent() 76 const content = await getFileContent()
86 expect(content).to.equal('Prince Ali') 77 expect(content).to.equal('Prince Ali')
87 }) 78 })
88 79
89 it('Should still have the file after the reinstallation', async function () { 80 it('Should still have the file after the reinstallation', async function () {
90 await installPlugin({ 81 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
91 url: server.url,
92 accessToken: server.accessToken,
93 path: getPluginTestPath('-six')
94 })
95 82
96 const content = await getFileContent() 83 const content = await getFileContent()
97 expect(content).to.equal('Prince Ali') 84 expect(content).to.equal('Prince Ali')