From c55e3d7227fe1453869e309025996b9d75256d5d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Dec 2021 11:58:15 +0100 Subject: Move test functions outside extra-utils --- .../mock-servers/mock-object-storage.ts | 41 ---------------------- 1 file changed, 41 deletions(-) delete mode 100644 shared/server-commands/mock-servers/mock-object-storage.ts (limited to 'shared/server-commands/mock-servers/mock-object-storage.ts') diff --git a/shared/server-commands/mock-servers/mock-object-storage.ts b/shared/server-commands/mock-servers/mock-object-storage.ts deleted file mode 100644 index d135c2631..000000000 --- a/shared/server-commands/mock-servers/mock-object-storage.ts +++ /dev/null @@ -1,41 +0,0 @@ -import express from 'express' -import got, { RequestError } from 'got' -import { Server } from 'http' -import { pipeline } from 'stream' -import { ObjectStorageCommand } from '../server' -import { getPort, randomListen, terminateServer } from './utils' - -export class MockObjectStorage { - private server: Server - - async initialize () { - const app = express() - - app.get('/:bucketName/:path(*)', (req: express.Request, res: express.Response, next: express.NextFunction) => { - const url = `http://${req.params.bucketName}.${ObjectStorageCommand.getEndpointHost()}/${req.params.path}` - - if (process.env.DEBUG) { - console.log('Receiving request on mocked server %s.', req.url) - console.log('Proxifying request to %s', url) - } - - return pipeline( - got.stream(url, { throwHttpErrors: false }), - res, - (err: RequestError) => { - if (!err) return - - console.error('Pipeline failed.', err) - } - ) - }) - - this.server = await randomListen(app) - - return getPort(this.server) - } - - terminate () { - return terminateServer(this.server) - } -} -- cgit v1.2.3