-
-
Notifications
You must be signed in to change notification settings - Fork 182
/
test-container.ts
110 lines (71 loc) · 2.29 KB
/
test-container.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { PortWithOptionalBinding } from "./port";
import { PullPolicy } from "./pull-policy";
import { WaitStrategy } from "./wait-strategy";
import { Readable } from "stream";
import {
ExecResult,
ExtraHost,
TmpFs,
Labels,
Ulimits,
BindMount,
FileToCopy,
ContentToCopy,
Environment,
} from "./docker/types";
import { StartedNetwork } from "./network";
export interface TestContainer {
start(): Promise<StartedTestContainer>;
withEnvironment(environment: Environment): this;
withCommand(command: string[]): this;
withEntrypoint(entrypoint: string[]): this;
withTmpFs(tmpFs: TmpFs): this;
withUlimits(ulimits: Ulimits): this;
withAddedCapabilities(...capabilities: string[]): this;
withDroppedCapabilities(...capabilities: string[]): this;
withExposedPorts(...ports: PortWithOptionalBinding[]): this;
withBindMounts(bindMounts: BindMount[]): this;
withWaitStrategy(waitStrategy: WaitStrategy): this;
withStartupTimeout(startupTimeout: number): this;
withNetwork(network: StartedNetwork): this;
withNetworkMode(networkMode: string): this;
withExtraHosts(extraHosts: ExtraHost[]): this;
withDefaultLogDriver(): this;
withPrivilegedMode(): this;
withUser(user: string): this;
withPullPolicy(pullPolicy: PullPolicy): this;
withReuse(): this;
withCopyFilesToContainer(filesToCopy: FileToCopy[]): this;
withCopyContentToContainer(contentsToCopy: ContentToCopy[]): this;
}
export interface RestartOptions {
timeout: number;
}
export interface StopOptions {
timeout: number;
removeVolumes: boolean;
}
export interface DockerComposeDownOptions {
timeout: number;
removeVolumes: boolean;
}
export interface ExecOptions {
tty: boolean;
detach: boolean;
stdin: boolean;
}
export interface StartedTestContainer {
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
restart(options?: Partial<RestartOptions>): Promise<void>;
getHost(): string;
getMappedPort(port: number): number;
getName(): string;
getLabels(): Labels;
getId(): string;
getNetworkNames(): string[];
getNetworkId(networkName: string): string;
getIpAddress(networkName: string): string;
exec(command: string[], options?: Partial<ExecOptions>): Promise<ExecResult>;
logs(): Promise<Readable>;
}
export interface StoppedTestContainer {}