forked from testcontainers/testcontainers-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-container.ts
More file actions
86 lines (80 loc) · 2.98 KB
/
test-container.ts
File metadata and controls
86 lines (80 loc) · 2.98 KB
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
import { WaitStrategy } from "./wait-strategies/wait-strategy";
import { Readable } from "stream";
import {
BindMount,
ContentToCopy,
DirectoryToCopy,
Environment,
ExecOptions,
ExecResult,
ExtraHost,
FileToCopy,
Labels,
ResourcesQuota,
TmpFs,
Ulimits,
} from "./types";
import { StartedNetwork } from "./network/network";
import { PortWithOptionalBinding } from "./utils/port";
import { ImagePullPolicy } from "./utils/pull-policy";
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(startupTimeoutMs: number): this;
withNetwork(network: StartedNetwork): this;
withNetworkMode(networkMode: string): this;
withExtraHosts(extraHosts: ExtraHost[]): this;
withDefaultLogDriver(): this;
withPrivilegedMode(): this;
withPlatform(platform: string): this;
withUser(user: string): this;
withPullPolicy(pullPolicy: ImagePullPolicy): this;
withReuse(): this;
withCopyFilesToContainer(filesToCopy: FileToCopy[]): this;
withCopyDirectoriesToContainer(directoriesToCopy: DirectoryToCopy[]): this;
withCopyContentToContainer(contentsToCopy: ContentToCopy[]): this;
withWorkingDir(workingDir: string): this;
withResourcesQuota(resourcesQuota: ResourcesQuota): this;
withSharedMemorySize(bytes: number): this;
withLogConsumer(logConsumer: (stream: Readable) => unknown): this;
}
export interface RestartOptions {
timeout: number;
}
export interface StopOptions {
timeout: number;
remove: boolean;
removeVolumes: boolean;
}
export interface StartedTestContainer {
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
restart(options?: Partial<RestartOptions>): Promise<void>;
getHost(): string;
getFirstMappedPort(): number;
getMappedPort(port: number): number;
getName(): string;
getLabels(): Labels;
getId(): string;
getNetworkNames(): string[];
getNetworkId(networkName: string): string;
getIpAddress(networkName: string): string;
copyArchiveFromContainer(path: string): Promise<NodeJS.ReadableStream>;
copyDirectoriesToContainer(directoriesToCopy: DirectoryToCopy[]): Promise<void>;
copyFilesToContainer(filesToCopy: FileToCopy[]): Promise<void>;
copyContentToContainer(contentsToCopy: ContentToCopy[]): Promise<void>;
exec(command: string | string[], opts?: Partial<ExecOptions>): Promise<ExecResult>;
logs(opts?: { since?: number; tail?: number }): Promise<Readable>;
}
export interface StoppedTestContainer {
getId(): string;
copyArchiveFromContainer(path: string): Promise<NodeJS.ReadableStream>;
}