@wocker/testing 1.0.0 → 1.0.2
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 +2 -0
- package/lib/index.js +2 -0
- package/lib/makes/Test.d.ts +3 -2
- package/lib/makes/Test.js +3 -14
- package/lib/makes/TestingModuleBuilder.d.ts +14 -0
- package/lib/makes/TestingModuleBuilder.js +56 -0
- package/lib/modem/index.d.ts +3 -0
- package/lib/modem/index.js +19 -0
- package/lib/modem/makes/DockerStorage.d.ts +268 -0
- package/lib/modem/makes/DockerStorage.js +528 -0
- package/lib/modem/makes/Fixtures.d.ts +18 -0
- package/lib/modem/makes/Fixtures.js +109 -0
- package/lib/modem/makes/FixturesGen.d.ts +5 -0
- package/lib/modem/makes/FixturesGen.js +18 -0
- package/lib/modem/makes/ModemMock.d.ts +16 -0
- package/lib/modem/makes/ModemMock.js +46 -0
- package/lib/modem/makes/ModemRecorder.d.ts +14 -0
- package/lib/modem/makes/ModemRecorder.js +60 -0
- package/lib/modem/router/Request.d.ts +9 -0
- package/lib/modem/router/Request.js +13 -0
- package/lib/modem/router/Response.d.ts +7 -0
- package/lib/modem/router/Response.js +17 -0
- package/lib/modem/router/Router.d.ts +20 -0
- package/lib/modem/router/Router.js +104 -0
- package/lib/modem/router/index.d.ts +3 -0
- package/lib/modem/router/index.js +19 -0
- package/lib/modem/types/Container.d.ts +10 -0
- package/lib/modem/types/Container.js +2 -0
- package/lib/modem/types/HttpMethod.d.ts +1 -0
- package/lib/modem/types/HttpMethod.js +2 -0
- package/lib/modem/types/Image.d.ts +8 -0
- package/lib/modem/types/Image.js +2 -0
- package/lib/services/MockProcessService.d.ts +7 -0
- package/lib/services/MockProcessService.js +42 -0
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +17 -0
- package/package.json +11 -4
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,3 +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
|
+
__exportStar(require("./services"), exports);
|
package/lib/makes/Test.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleMetadata } from "@wocker/core";
|
|
2
|
+
import { TestingModuleBuilder } from "./TestingModuleBuilder";
|
|
2
3
|
export declare class Test {
|
|
3
|
-
static createTestingModule(
|
|
4
|
+
static createTestingModule(metadata: ModuleMetadata): TestingModuleBuilder;
|
|
4
5
|
}
|
package/lib/makes/Test.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.Test = void 0;
|
|
10
|
-
const
|
|
4
|
+
const TestingModuleBuilder_1 = require("./TestingModuleBuilder");
|
|
11
5
|
class Test {
|
|
12
|
-
static
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
TestModule = __decorate([
|
|
16
|
-
(0, core_1.Module)(config)
|
|
17
|
-
], TestModule);
|
|
18
|
-
return core_1.Factory.create(TestModule);
|
|
6
|
+
static createTestingModule(metadata) {
|
|
7
|
+
return new TestingModuleBuilder_1.TestingModuleBuilder(metadata);
|
|
19
8
|
}
|
|
20
9
|
}
|
|
21
10
|
exports.Test = Test;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleMetadata, ApplicationContext, InjectionToken, ProviderType } from "@wocker/core";
|
|
2
|
+
export declare class TestingModuleBuilder {
|
|
3
|
+
protected readonly moduleType: any;
|
|
4
|
+
protected readonly overrideProviders: Map<InjectionToken, ProviderType>;
|
|
5
|
+
constructor(metadata: ModuleMetadata);
|
|
6
|
+
protected createModule(metadata: ModuleMetadata): {
|
|
7
|
+
new (): {};
|
|
8
|
+
};
|
|
9
|
+
overrideProvider(token: InjectionToken): {
|
|
10
|
+
useProvider(type: ProviderType): TestingModuleBuilder;
|
|
11
|
+
useValue(value: any): TestingModuleBuilder;
|
|
12
|
+
};
|
|
13
|
+
build(): Promise<ApplicationContext>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TestingModuleBuilder = void 0;
|
|
10
|
+
const core_1 = require("@wocker/core");
|
|
11
|
+
class TestingModuleBuilder {
|
|
12
|
+
constructor(metadata) {
|
|
13
|
+
this.moduleType = this.createModule(metadata);
|
|
14
|
+
this.overrideProviders = new Map();
|
|
15
|
+
}
|
|
16
|
+
createModule(metadata) {
|
|
17
|
+
let TestingModule = class TestingModule {
|
|
18
|
+
};
|
|
19
|
+
TestingModule = __decorate([
|
|
20
|
+
(0, core_1.Global)(),
|
|
21
|
+
(0, core_1.Module)(metadata)
|
|
22
|
+
], TestingModule);
|
|
23
|
+
return TestingModule;
|
|
24
|
+
}
|
|
25
|
+
overrideProvider(token) {
|
|
26
|
+
const _this = this;
|
|
27
|
+
return {
|
|
28
|
+
useProvider(type) {
|
|
29
|
+
_this.overrideProviders.set(token, type);
|
|
30
|
+
return _this;
|
|
31
|
+
},
|
|
32
|
+
useValue(value) {
|
|
33
|
+
_this.overrideProviders.set(token, {
|
|
34
|
+
provide: token,
|
|
35
|
+
useValue: value
|
|
36
|
+
});
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async build() {
|
|
42
|
+
const _this = this;
|
|
43
|
+
class TestScanner extends core_1.Scanner {
|
|
44
|
+
scanRoutes() {
|
|
45
|
+
_this.overrideProviders.forEach((provider, token) => {
|
|
46
|
+
this.container.replace(token, provider);
|
|
47
|
+
});
|
|
48
|
+
super.scanRoutes();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const scanner = new TestScanner();
|
|
52
|
+
await scanner.scan(this.moduleType);
|
|
53
|
+
return new core_1.ApplicationContext(this.moduleType, scanner.container);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TestingModuleBuilder = TestingModuleBuilder;
|
|
@@ -0,0 +1,19 @@
|
|
|
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);
|
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
}
|