diff options
Diffstat (limited to 'server/tests/shared')
-rw-r--r-- | server/tests/shared/checks.ts | 9 | ||||
-rw-r--r-- | server/tests/shared/mock-servers/index.ts | 1 | ||||
-rw-r--r-- | server/tests/shared/mock-servers/mock-http.ts | 23 |
3 files changed, 32 insertions, 1 deletions
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) { | |||
29 | expect(content.toString()).to.not.contain(str) | 29 | expect(content.toString()).to.not.contain(str) |
30 | } | 30 | } |
31 | 31 | ||
32 | async function expectLogContain (server: PeerTubeServer, str: string) { | ||
33 | const content = await server.servers.getLogContent() | ||
34 | |||
35 | expect(content.toString()).to.contain(str) | ||
36 | } | ||
37 | |||
32 | async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { | 38 | async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { |
33 | const res = await makeGetRequest({ | 39 | const res = await makeGetRequest({ |
34 | url, | 40 | url, |
@@ -99,5 +105,6 @@ export { | |||
99 | expectNotStartWith, | 105 | expectNotStartWith, |
100 | checkBadStartPagination, | 106 | checkBadStartPagination, |
101 | checkBadCountPagination, | 107 | checkBadCountPagination, |
102 | checkBadSortPagination | 108 | checkBadSortPagination, |
109 | expectLogContain | ||
103 | } | 110 | } |
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 @@ | |||
1 | export * from './mock-429' | 1 | export * from './mock-429' |
2 | export * from './mock-email' | 2 | export * from './mock-email' |
3 | export * from './mock-http' | ||
3 | export * from './mock-instances-index' | 4 | export * from './mock-instances-index' |
4 | export * from './mock-joinpeertube-versions' | 5 | export * from './mock-joinpeertube-versions' |
5 | export * from './mock-object-storage' | 6 | 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 @@ | |||
1 | import express from 'express' | ||
2 | import { Server } from 'http' | ||
3 | import { getPort, randomListen, terminateServer } from './shared' | ||
4 | |||
5 | export class MockHTTP { | ||
6 | private server: Server | ||
7 | |||
8 | async initialize () { | ||
9 | const app = express() | ||
10 | |||
11 | app.get('/*', (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
12 | return res.sendStatus(200) | ||
13 | }) | ||
14 | |||
15 | this.server = await randomListen(app) | ||
16 | |||
17 | return getPort(this.server) | ||
18 | } | ||
19 | |||
20 | terminate () { | ||
21 | return terminateServer(this.server) | ||
22 | } | ||
23 | } | ||