@wocker/testing 1.0.3 → 1.0.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/makes/TestingModuleBuilder.d.ts +5 -1
- package/lib/makes/TestingModuleBuilder.js +19 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/{modem/router → utils}/index.js +1 -3
- package/lib/utils/utilsMock.d.ts +12 -0
- package/lib/utils/utilsMock.js +15 -0
- package/package.json +2 -3
- package/lib/modem/index.d.ts +0 -3
- package/lib/modem/index.js +0 -19
- package/lib/modem/makes/DockerStorage.d.ts +0 -268
- package/lib/modem/makes/DockerStorage.js +0 -528
- package/lib/modem/makes/Fixtures.d.ts +0 -18
- package/lib/modem/makes/Fixtures.js +0 -109
- package/lib/modem/makes/FixturesGen.d.ts +0 -5
- package/lib/modem/makes/FixturesGen.js +0 -18
- package/lib/modem/makes/ModemMock.d.ts +0 -16
- package/lib/modem/makes/ModemMock.js +0 -46
- package/lib/modem/makes/ModemRecorder.d.ts +0 -14
- package/lib/modem/makes/ModemRecorder.js +0 -60
- package/lib/modem/router/Request.d.ts +0 -9
- package/lib/modem/router/Request.js +0 -13
- package/lib/modem/router/Response.d.ts +0 -7
- package/lib/modem/router/Response.js +0 -17
- package/lib/modem/router/Router.d.ts +0 -20
- package/lib/modem/router/Router.js +0 -104
- package/lib/modem/router/index.d.ts +0 -3
- package/lib/modem/types/Container.d.ts +0 -10
- package/lib/modem/types/Container.js +0 -2
- package/lib/modem/types/HttpMethod.d.ts +0 -1
- package/lib/modem/types/HttpMethod.js +0 -2
- package/lib/modem/types/Image.d.ts +0 -8
- package/lib/modem/types/Image.js +0 -2
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./makes"), exports);
|
|
18
|
-
__exportStar(require("./modem"), exports);
|
|
19
18
|
__exportStar(require("./services"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ApplicationContext, InjectionToken, ProviderType, Type, ModuleMetadata } from "@wocker/core";
|
|
1
|
+
import { ApplicationContext, InjectionToken, ProviderType, DynamicModule, Type, ModuleMetadata } from "@wocker/core";
|
|
2
2
|
export declare class TestingModuleBuilder {
|
|
3
3
|
protected readonly moduleType: Type;
|
|
4
4
|
protected readonly overrideProviders: Map<InjectionToken, ProviderType>;
|
|
5
|
+
protected readonly overrideModules: Map<Type, Type | DynamicModule>;
|
|
5
6
|
constructor(metadata: ModuleMetadata);
|
|
6
7
|
protected createModule(metadata: ModuleMetadata): {
|
|
7
8
|
new (): {};
|
|
@@ -10,5 +11,8 @@ export declare class TestingModuleBuilder {
|
|
|
10
11
|
useProvider(type: ProviderType): TestingModuleBuilder;
|
|
11
12
|
useValue(value: any): TestingModuleBuilder;
|
|
12
13
|
};
|
|
14
|
+
overrideModule(module: Type): {
|
|
15
|
+
useModule: (newModule: Type | DynamicModule) => TestingModuleBuilder;
|
|
16
|
+
};
|
|
13
17
|
build(): Promise<ApplicationContext>;
|
|
14
18
|
}
|
|
@@ -13,6 +13,7 @@ class TestingModuleBuilder {
|
|
|
13
13
|
constructor(metadata) {
|
|
14
14
|
this.moduleType = this.createModule(metadata);
|
|
15
15
|
this.overrideProviders = new Map();
|
|
16
|
+
this.overrideModules = new Map();
|
|
16
17
|
this.overrideProvider(core_1.ProcessService)
|
|
17
18
|
.useProvider(services_1.MockProcessService);
|
|
18
19
|
}
|
|
@@ -41,9 +42,27 @@ class TestingModuleBuilder {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
}
|
|
45
|
+
overrideModule(module) {
|
|
46
|
+
const _this = this;
|
|
47
|
+
return {
|
|
48
|
+
useModule: (newModule) => {
|
|
49
|
+
this.overrideModules.set(module, newModule);
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
44
54
|
async build() {
|
|
45
55
|
const _this = this;
|
|
46
56
|
class TestScanner extends core_1.Scanner {
|
|
57
|
+
scanModule(moduleDefinition) {
|
|
58
|
+
const type = this.isDynamicModule(moduleDefinition)
|
|
59
|
+
? moduleDefinition.module
|
|
60
|
+
: moduleDefinition;
|
|
61
|
+
if (_this.overrideModules.has(type)) {
|
|
62
|
+
return super.scanModule(_this.overrideModules.get(type));
|
|
63
|
+
}
|
|
64
|
+
return super.scanModule(moduleDefinition);
|
|
65
|
+
}
|
|
47
66
|
scanRoutes() {
|
|
48
67
|
_this.overrideProviders.forEach((provider, token) => {
|
|
49
68
|
this.container.replace(token, provider);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utilsMock";
|
|
@@ -14,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./Response"), exports);
|
|
19
|
-
__exportStar(require("./Router"), exports);
|
|
17
|
+
__exportStar(require("./utilsMock"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const utilsMock: {
|
|
2
|
+
promptInput: ({ message }: {
|
|
3
|
+
message: any;
|
|
4
|
+
}) => any;
|
|
5
|
+
promptSelect: ({ message }: {
|
|
6
|
+
message: any;
|
|
7
|
+
}) => any;
|
|
8
|
+
promptConfirm: ({ message }: {
|
|
9
|
+
message: any;
|
|
10
|
+
}) => any;
|
|
11
|
+
setPromptMock: (map: any) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.utilsMock = void 0;
|
|
4
|
+
let promptMap = {};
|
|
5
|
+
const prompt = ({ message }) => {
|
|
6
|
+
return promptMap[message];
|
|
7
|
+
};
|
|
8
|
+
exports.utilsMock = {
|
|
9
|
+
promptInput: prompt,
|
|
10
|
+
promptSelect: prompt,
|
|
11
|
+
promptConfirm: prompt,
|
|
12
|
+
setPromptMock: (map) => {
|
|
13
|
+
promptMap = map;
|
|
14
|
+
}
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/testing",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4-beta.1",
|
|
5
5
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
6
6
|
"description": "Docker workspace for web projects (testing)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"memfs": "^4.17.2",
|
|
45
45
|
"ts-jest": "^29.4.4",
|
|
46
46
|
"ts-node": "^10.9.2",
|
|
47
|
-
"typescript": "^5.9.2"
|
|
48
|
-
"unionfs": "^4.5.4"
|
|
47
|
+
"typescript": "^5.9.2"
|
|
49
48
|
}
|
|
50
49
|
}
|
package/lib/modem/index.d.ts
DELETED
package/lib/modem/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./makes/Fixtures"), exports);
|
|
18
|
-
__exportStar(require("./makes/ModemMock"), exports);
|
|
19
|
-
__exportStar(require("./makes/ModemRecorder"), exports);
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from "http";
|
|
2
|
-
import { Readable } from "stream";
|
|
3
|
-
import { Router } from "../router";
|
|
4
|
-
import { Fixtures } from "./Fixtures";
|
|
5
|
-
import { HttpMethod } from "../types/HttpMethod";
|
|
6
|
-
import { Container } from "../types/Container";
|
|
7
|
-
import { Image } from "../types/Image";
|
|
8
|
-
export declare class DockerStorage {
|
|
9
|
-
protected containers: Container[];
|
|
10
|
-
protected images: Image[];
|
|
11
|
-
protected fixtures: Fixtures[];
|
|
12
|
-
protected router: Router;
|
|
13
|
-
constructor();
|
|
14
|
-
listContainers(body: any): any[];
|
|
15
|
-
createContainer(info: any): string;
|
|
16
|
-
run(id: string): void;
|
|
17
|
-
containerInspect(id: string): {
|
|
18
|
-
Id: string;
|
|
19
|
-
Name: string;
|
|
20
|
-
Created: string;
|
|
21
|
-
Path: string;
|
|
22
|
-
Args: string[];
|
|
23
|
-
State: {
|
|
24
|
-
Status: string;
|
|
25
|
-
Running: boolean;
|
|
26
|
-
Paused: boolean;
|
|
27
|
-
Restarting: boolean;
|
|
28
|
-
OOMKilled: boolean;
|
|
29
|
-
Dead: boolean;
|
|
30
|
-
Pid: number;
|
|
31
|
-
ExitCode: number;
|
|
32
|
-
Error: string;
|
|
33
|
-
StartedAt: string;
|
|
34
|
-
FinishedAt: string;
|
|
35
|
-
};
|
|
36
|
-
Image: string;
|
|
37
|
-
ResolvConfPath: string;
|
|
38
|
-
HostnamePath: string;
|
|
39
|
-
HostsPath: string;
|
|
40
|
-
LogPath: string;
|
|
41
|
-
RestartCount: number;
|
|
42
|
-
Driver: string;
|
|
43
|
-
Platform: string;
|
|
44
|
-
MountLabel: string;
|
|
45
|
-
ProcessLabel: string;
|
|
46
|
-
AppArmorProfile: string;
|
|
47
|
-
ExecIDs: any;
|
|
48
|
-
HostConfig: {
|
|
49
|
-
Binds: any;
|
|
50
|
-
ContainerIDFile: string;
|
|
51
|
-
LogConfig: {
|
|
52
|
-
Type: string;
|
|
53
|
-
Config: {};
|
|
54
|
-
};
|
|
55
|
-
NetworkMode: string;
|
|
56
|
-
PortBindings: {};
|
|
57
|
-
RestartPolicy: {
|
|
58
|
-
Name: string;
|
|
59
|
-
MaximumRetryCount: number;
|
|
60
|
-
};
|
|
61
|
-
AutoRemove: boolean;
|
|
62
|
-
VolumeDriver: string;
|
|
63
|
-
VolumesFrom: any;
|
|
64
|
-
ConsoleSize: number[];
|
|
65
|
-
CapAdd: any;
|
|
66
|
-
CapDrop: any;
|
|
67
|
-
CgroupnsMode: string;
|
|
68
|
-
Dns: any;
|
|
69
|
-
DnsOptions: any;
|
|
70
|
-
DnsSearch: any;
|
|
71
|
-
ExtraHosts: any;
|
|
72
|
-
GroupAdd: any;
|
|
73
|
-
IpcMode: string;
|
|
74
|
-
Cgroup: string;
|
|
75
|
-
Links: any;
|
|
76
|
-
OomScoreAdj: number;
|
|
77
|
-
PidMode: string;
|
|
78
|
-
Privileged: boolean;
|
|
79
|
-
PublishAllPorts: boolean;
|
|
80
|
-
ReadonlyRootfs: boolean;
|
|
81
|
-
SecurityOpt: any;
|
|
82
|
-
UTSMode: string;
|
|
83
|
-
UsernsMode: string;
|
|
84
|
-
ShmSize: number;
|
|
85
|
-
Runtime: string;
|
|
86
|
-
Isolation: string;
|
|
87
|
-
CpuShares: number;
|
|
88
|
-
Memory: number;
|
|
89
|
-
NanoCpus: number;
|
|
90
|
-
CgroupParent: string;
|
|
91
|
-
BlkioWeight: number;
|
|
92
|
-
BlkioWeightDevice: any;
|
|
93
|
-
BlkioDeviceReadBps: any;
|
|
94
|
-
BlkioDeviceWriteBps: any;
|
|
95
|
-
BlkioDeviceReadIOps: any;
|
|
96
|
-
BlkioDeviceWriteIOps: any;
|
|
97
|
-
CpuPeriod: number;
|
|
98
|
-
CpuQuota: number;
|
|
99
|
-
CpuRealtimePeriod: number;
|
|
100
|
-
CpuRealtimeRuntime: number;
|
|
101
|
-
CpusetCpus: string;
|
|
102
|
-
CpusetMems: string;
|
|
103
|
-
Devices: any;
|
|
104
|
-
DeviceCgroupRules: any;
|
|
105
|
-
DeviceRequests: any;
|
|
106
|
-
MemoryReservation: number;
|
|
107
|
-
MemorySwap: number;
|
|
108
|
-
MemorySwappiness: any;
|
|
109
|
-
OomKillDisable: boolean;
|
|
110
|
-
PidsLimit: any;
|
|
111
|
-
Ulimits: any;
|
|
112
|
-
CpuCount: number;
|
|
113
|
-
CpuPercent: number;
|
|
114
|
-
IOMaximumIOps: number;
|
|
115
|
-
IOMaximumBandwidth: number;
|
|
116
|
-
MaskedPaths: string[];
|
|
117
|
-
ReadonlyPaths: string[];
|
|
118
|
-
};
|
|
119
|
-
GraphDriver: {
|
|
120
|
-
Data: any;
|
|
121
|
-
Name: string;
|
|
122
|
-
};
|
|
123
|
-
Mounts: any[];
|
|
124
|
-
Config: {
|
|
125
|
-
Hostname: string;
|
|
126
|
-
Domainname: string;
|
|
127
|
-
User: string;
|
|
128
|
-
AttachStdin: boolean;
|
|
129
|
-
AttachStdout: boolean;
|
|
130
|
-
AttachStderr: boolean;
|
|
131
|
-
Tty: boolean;
|
|
132
|
-
OpenStdin: boolean;
|
|
133
|
-
StdinOnce: boolean;
|
|
134
|
-
Env: string[];
|
|
135
|
-
Cmd: string[];
|
|
136
|
-
Image: string;
|
|
137
|
-
Volumes: any;
|
|
138
|
-
WorkingDir: string;
|
|
139
|
-
Entrypoint: string[];
|
|
140
|
-
OnBuild: any;
|
|
141
|
-
Labels: {
|
|
142
|
-
"desktop.docker.io/wsl-distro": string;
|
|
143
|
-
"org.opencontainers.image.created": string;
|
|
144
|
-
"org.opencontainers.image.description": string;
|
|
145
|
-
"org.opencontainers.image.licenses": string;
|
|
146
|
-
"org.opencontainers.image.revision": string;
|
|
147
|
-
"org.opencontainers.image.source": string;
|
|
148
|
-
"org.opencontainers.image.title": string;
|
|
149
|
-
"org.opencontainers.image.url": string;
|
|
150
|
-
"org.opencontainers.image.version": string;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
NetworkSettings: {
|
|
154
|
-
Bridge: string;
|
|
155
|
-
SandboxID: string;
|
|
156
|
-
SandboxKey: string;
|
|
157
|
-
Ports: {};
|
|
158
|
-
HairpinMode: boolean;
|
|
159
|
-
LinkLocalIPv6Address: string;
|
|
160
|
-
LinkLocalIPv6PrefixLen: number;
|
|
161
|
-
SecondaryIPAddresses: any;
|
|
162
|
-
SecondaryIPv6Addresses: any;
|
|
163
|
-
EndpointID: string;
|
|
164
|
-
Gateway: string;
|
|
165
|
-
GlobalIPv6Address: string;
|
|
166
|
-
GlobalIPv6PrefixLen: number;
|
|
167
|
-
IPAddress: string;
|
|
168
|
-
IPPrefixLen: number;
|
|
169
|
-
IPv6Gateway: string;
|
|
170
|
-
MacAddress: string;
|
|
171
|
-
Networks: {
|
|
172
|
-
bridge: {
|
|
173
|
-
IPAMConfig: any;
|
|
174
|
-
Links: any;
|
|
175
|
-
Aliases: any;
|
|
176
|
-
MacAddress: string;
|
|
177
|
-
DriverOpts: any;
|
|
178
|
-
GwPriority: number;
|
|
179
|
-
NetworkID: string;
|
|
180
|
-
EndpointID: string;
|
|
181
|
-
Gateway: string;
|
|
182
|
-
IPAddress: string;
|
|
183
|
-
IPPrefixLen: number;
|
|
184
|
-
IPv6Gateway: string;
|
|
185
|
-
GlobalIPv6Address: string;
|
|
186
|
-
GlobalIPv6PrefixLen: number;
|
|
187
|
-
DNSNames: any;
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
ImageManifestDescriptor: {
|
|
192
|
-
mediaType: string;
|
|
193
|
-
digest: string;
|
|
194
|
-
size: number;
|
|
195
|
-
platform: {
|
|
196
|
-
architecture: string;
|
|
197
|
-
os: string;
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
imageList(body: any): any[];
|
|
202
|
-
imageInspect(tag: string): {
|
|
203
|
-
Id: string;
|
|
204
|
-
RepoTags: string[];
|
|
205
|
-
RepoDigests: string[];
|
|
206
|
-
Parent: string;
|
|
207
|
-
Comment: string;
|
|
208
|
-
Created: string;
|
|
209
|
-
DockerVersion: string;
|
|
210
|
-
Author: string;
|
|
211
|
-
Config: {
|
|
212
|
-
Hostname: string;
|
|
213
|
-
Domainname: string;
|
|
214
|
-
User: string;
|
|
215
|
-
AttachStdin: boolean;
|
|
216
|
-
AttachStdout: boolean;
|
|
217
|
-
AttachStderr: boolean;
|
|
218
|
-
Tty: boolean;
|
|
219
|
-
OpenStdin: boolean;
|
|
220
|
-
StdinOnce: boolean;
|
|
221
|
-
Env: string[];
|
|
222
|
-
Cmd: string[];
|
|
223
|
-
ArgsEscaped: boolean;
|
|
224
|
-
Image: string;
|
|
225
|
-
Volumes: any;
|
|
226
|
-
WorkingDir: string;
|
|
227
|
-
Entrypoint: string[];
|
|
228
|
-
OnBuild: any;
|
|
229
|
-
Labels: {
|
|
230
|
-
"org.opencontainers.image.created": string;
|
|
231
|
-
"org.opencontainers.image.description": string;
|
|
232
|
-
"org.opencontainers.image.licenses": string;
|
|
233
|
-
"org.opencontainers.image.revision": string;
|
|
234
|
-
"org.opencontainers.image.source": string;
|
|
235
|
-
"org.opencontainers.image.title": string;
|
|
236
|
-
"org.opencontainers.image.url": string;
|
|
237
|
-
"org.opencontainers.image.version": string;
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
Architecture: string;
|
|
241
|
-
Os: string;
|
|
242
|
-
Size: number;
|
|
243
|
-
GraphDriver: {
|
|
244
|
-
Data: any;
|
|
245
|
-
Name: string;
|
|
246
|
-
};
|
|
247
|
-
RootFS: {
|
|
248
|
-
Type: string;
|
|
249
|
-
Layers: string[];
|
|
250
|
-
};
|
|
251
|
-
Metadata: {
|
|
252
|
-
LastTagTime: string;
|
|
253
|
-
};
|
|
254
|
-
Descriptor: {
|
|
255
|
-
mediaType: string;
|
|
256
|
-
digest: string;
|
|
257
|
-
size: number;
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
imagePull(version: string, imageName: string, tag: string): IncomingMessage;
|
|
261
|
-
imageDelete(imageTag: string): any;
|
|
262
|
-
build(version: string, body: any): Readable;
|
|
263
|
-
protected generateId(short?: boolean): string;
|
|
264
|
-
protected chunkedResponse(chunks: string[]): IncomingMessage;
|
|
265
|
-
registerFixtures(fixtures: Fixtures): void;
|
|
266
|
-
reset(): void;
|
|
267
|
-
exec(method: HttpMethod, path: string, body: any, options?: any): Promise<any>;
|
|
268
|
-
}
|