forked from aws/aws-lambda-nodejs-runtime-interface-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStubHttp.ts
More file actions
30 lines (25 loc) · 851 Bytes
/
StubHttp.ts
File metadata and controls
30 lines (25 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/** Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
import { RequestOptions, ClientRequest } from "http";
import { URL } from "url";
/**
* Stub request object.
* Provides no-op definitions of the request functions used by the Runtime Interface Client.
*/
export const noOpRequest = Object.freeze({
/* no op, return itself to allow continuations/chaining */
on: () => noOpRequest,
/* no op, return itself to allow continuations/chaninig */
end: () => noOpRequest,
});
export class StubHttp {
lastUsedOptions: RequestOptions | string | URL;
Agent: any;
constructor() {
this.lastUsedOptions = {};
this.Agent = class FakeAgent {};
}
request(options: RequestOptions | string | URL): ClientRequest {
this.lastUsedOptions = options;
return (noOpRequest as unknown) as ClientRequest;
}
}