mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Create single function for port generation
This reduces the chances of several integration tests re-using the same port.
This commit is contained in:
@@ -9,6 +9,26 @@ import type { HttpHandler } from '../../src/server/HttpHandler';
|
||||
import type { HttpRequest } from '../../src/server/HttpRequest';
|
||||
import type { SystemError } from '../../src/util/errors/SystemError';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
const portNames = [
|
||||
'DynamicPods',
|
||||
'Middleware',
|
||||
'PodCreation',
|
||||
'RedisResourceLocker',
|
||||
'ServerFetch',
|
||||
'Subdomains',
|
||||
'WebSocketsProtocol',
|
||||
] as const;
|
||||
|
||||
export function getPort(name: typeof portNames[number]): number {
|
||||
const idx = portNames.indexOf(name);
|
||||
// Just in case something doesn't listen to the typings
|
||||
if (idx < 0) {
|
||||
throw new Error(`Unknown port name ${name}`);
|
||||
}
|
||||
return 6000 + idx;
|
||||
}
|
||||
|
||||
export async function performRequest(
|
||||
handler: HttpHandler,
|
||||
requestUrl: URL,
|
||||
|
||||
Reference in New Issue
Block a user