From ae2abfd3aed3e75d39a316b49b914d187faa7475 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 10:33:49 +0200 Subject: Introduce plugins command --- server/tests/plugins/plugin-unloading.ts | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'server/tests/plugins/plugin-unloading.ts') diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 74ca82e2f..f430f82b8 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -1,18 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { - cleanupTests, - flushAndRunServer, - getPluginTestPath, - makeGetRequest, - installPlugin, - uninstallPlugin, - ServerInfo, - setAccessTokensToServers -} from '../../../shared/extra-utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { expect } from 'chai' +import { HttpStatusCode } from '@shared/core-utils' +import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' describe('Test plugins module unloading', function () { let server: ServerInfo = null @@ -25,11 +16,7 @@ describe('Test plugins module unloading', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-unloading') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) }) it('Should return a numeric value', async function () { @@ -54,11 +41,7 @@ describe('Test plugins module unloading', function () { }) it('Should uninstall the plugin and free the route', async function () { - await uninstallPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-test-unloading' - }) + await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' }) await makeGetRequest({ url: server.url, @@ -68,11 +51,8 @@ describe('Test plugins module unloading', function () { }) it('Should return a different numeric value', async function () { - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - path: getPluginTestPath('-unloading') - }) + await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) + const res = await makeGetRequest({ url: server.url, path: requestPath, -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/plugins/plugin-unloading.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/tests/plugins/plugin-unloading.ts') diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index f430f82b8..26a27abca 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -16,7 +16,7 @@ describe('Test plugins module unloading', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) + await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) }) it('Should return a numeric value', async function () { @@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () { }) it('Should uninstall the plugin and free the route', async function () { - await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' }) + await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' }) await makeGetRequest({ url: server.url, @@ -51,7 +51,7 @@ describe('Test plugins module unloading', function () { }) it('Should return a different numeric value', async function () { - await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) + await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) const res = await makeGetRequest({ url: server.url, -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/plugins/plugin-unloading.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'server/tests/plugins/plugin-unloading.ts') diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 26a27abca..6c405b7f5 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -3,17 +3,24 @@ import 'mocha' import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@shared/extra-utils' describe('Test plugins module unloading', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null const requestPath = '/plugins/test-unloading/router/get' let value: string = null before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/plugins/plugin-unloading.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'server/tests/plugins/plugin-unloading.ts') diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 6c405b7f5..faf9cc599 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, @@ -30,7 +30,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.match(/^\d+$/) @@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.be.equal(value) @@ -53,7 +53,7 @@ describe('Test plugins module unloading', function () { await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) @@ -63,7 +63,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.match(/^\d+$/) -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/plugins/plugin-unloading.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/plugins/plugin-unloading.ts') diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index faf9cc599..6bf2fda9b 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -2,7 +2,6 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, @@ -11,6 +10,7 @@ import { PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils' +import { HttpStatusCode } from '@shared/models' describe('Test plugins module unloading', function () { let server: PeerTubeServer = null -- cgit v1.2.3