From 630d0a1bf5897fff203cb07e426223f55dcc882d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 Jul 2022 15:43:21 +0200 Subject: Introduce experimental telemetry --- server/tests/shared/checks.ts | 9 ++++++++- server/tests/shared/mock-servers/index.ts | 1 + server/tests/shared/mock-servers/mock-http.ts | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 server/tests/shared/mock-servers/mock-http.ts (limited to 'server/tests/shared') diff --git a/server/tests/shared/checks.ts b/server/tests/shared/checks.ts index 33b917f31..55ebc6c3e 100644 --- a/server/tests/shared/checks.ts +++ b/server/tests/shared/checks.ts @@ -29,6 +29,12 @@ async function expectLogDoesNotContain (server: PeerTubeServer, str: string) { expect(content.toString()).to.not.contain(str) } +async function expectLogContain (server: PeerTubeServer, str: string) { + const content = await server.servers.getLogContent() + + expect(content.toString()).to.contain(str) +} + async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { const res = await makeGetRequest({ url, @@ -99,5 +105,6 @@ export { expectNotStartWith, checkBadStartPagination, checkBadCountPagination, - checkBadSortPagination + checkBadSortPagination, + expectLogContain } diff --git a/server/tests/shared/mock-servers/index.ts b/server/tests/shared/mock-servers/index.ts index abf4a8203..1fa983116 100644 --- a/server/tests/shared/mock-servers/index.ts +++ b/server/tests/shared/mock-servers/index.ts @@ -1,5 +1,6 @@ export * from './mock-429' export * from './mock-email' +export * from './mock-http' export * from './mock-instances-index' export * from './mock-joinpeertube-versions' export * from './mock-object-storage' diff --git a/server/tests/shared/mock-servers/mock-http.ts b/server/tests/shared/mock-servers/mock-http.ts new file mode 100644 index 000000000..b7a019e07 --- /dev/null +++ b/server/tests/shared/mock-servers/mock-http.ts @@ -0,0 +1,23 @@ +import express from 'express' +import { Server } from 'http' +import { getPort, randomListen, terminateServer } from './shared' + +export class MockHTTP { + private server: Server + + async initialize () { + const app = express() + + app.get('/*', (req: express.Request, res: express.Response, next: express.NextFunction) => { + return res.sendStatus(200) + }) + + this.server = await randomListen(app) + + return getPort(this.server) + } + + terminate () { + return terminateServer(this.server) + } +} -- cgit v1.2.3