From c8fc9b47188b33cfc33184b1ee7e680a093244f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 10:35:35 +0200 Subject: Rename mock server files --- shared/extra-utils/index.ts | 2 +- shared/extra-utils/mock-servers/index.ts | 2 ++ .../mock-servers/joinpeertube-versions.ts | 33 ---------------------- .../mock-servers/mock-joinpeertube-versions.ts | 33 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 shared/extra-utils/mock-servers/index.ts delete mode 100644 shared/extra-utils/mock-servers/joinpeertube-versions.ts create mode 100644 shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index a3d3970af..30f44dfc2 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts @@ -8,7 +8,7 @@ export * from './feeds' export * from './logs' -export * from './mock-servers/mock-instances-index' +export * from './mock-servers' export * from './miscs/email' export * from './miscs/sql' diff --git a/shared/extra-utils/mock-servers/index.ts b/shared/extra-utils/mock-servers/index.ts new file mode 100644 index 000000000..47679c818 --- /dev/null +++ b/shared/extra-utils/mock-servers/index.ts @@ -0,0 +1,2 @@ +export * from './mock-instances-index' +export * from './mock-joinpeertube-versions' diff --git a/shared/extra-utils/mock-servers/joinpeertube-versions.ts b/shared/extra-utils/mock-servers/joinpeertube-versions.ts deleted file mode 100644 index 5ea432ecf..000000000 --- a/shared/extra-utils/mock-servers/joinpeertube-versions.ts +++ /dev/null @@ -1,33 +0,0 @@ -import * as express from 'express' -import { randomInt } from '@shared/core-utils' - -export class MockJoinPeerTubeVersions { - private latestVersion: string - - initialize () { - return new Promise(res => { - const app = express() - - app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { - if (process.env.DEBUG) console.log('Receiving request on mocked server %s.', req.url) - - return next() - }) - - app.get('/versions.json', (req: express.Request, res: express.Response) => { - return res.json({ - peertube: { - latestVersion: this.latestVersion - } - }) - }) - - const port = 42201 + randomInt(1, 100) - app.listen(port, () => res(port)) - }) - } - - setLatestVersion (latestVersion: string) { - this.latestVersion = latestVersion - } -} diff --git a/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts new file mode 100644 index 000000000..5ea432ecf --- /dev/null +++ b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts @@ -0,0 +1,33 @@ +import * as express from 'express' +import { randomInt } from '@shared/core-utils' + +export class MockJoinPeerTubeVersions { + private latestVersion: string + + initialize () { + return new Promise(res => { + const app = express() + + app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { + if (process.env.DEBUG) console.log('Receiving request on mocked server %s.', req.url) + + return next() + }) + + app.get('/versions.json', (req: express.Request, res: express.Response) => { + return res.json({ + peertube: { + latestVersion: this.latestVersion + } + }) + }) + + const port = 42201 + randomInt(1, 100) + app.listen(port, () => res(port)) + }) + } + + setLatestVersion (latestVersion: string) { + this.latestVersion = latestVersion + } +} -- cgit v1.2.3