forked from testcontainers/testcontainers-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstract-started-container.ts
More file actions
110 lines (83 loc) · 3.5 KB
/
abstract-started-container.ts
File metadata and controls
110 lines (83 loc) · 3.5 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
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 { Readable } from "stream";
import { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
import { CommitOptions, ContentToCopy, DirectoryToCopy, ExecOptions, ExecResult, FileToCopy, Labels } from "../types";
export class AbstractStartedContainer implements StartedTestContainer {
constructor(protected readonly startedTestContainer: StartedTestContainer) {}
protected containerStopping?(): Promise<void>;
public async stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer> {
if (this.containerStopping) {
await this.containerStopping();
}
const stoppedContainer = await this.startedTestContainer.stop(options);
if (this.containerStopped) {
await this.containerStopped();
}
return stoppedContainer;
}
protected containerStopped?(): Promise<void>;
public async restart(options?: Partial<RestartOptions>): Promise<void> {
return this.startedTestContainer.restart(options);
}
public async commit(options: CommitOptions): Promise<string> {
return this.startedTestContainer.commit(options);
}
public getHost(): string {
return this.startedTestContainer.getHost();
}
public getHostname(): string {
return this.startedTestContainer.getHostname();
}
public getFirstMappedPort(): number {
return this.startedTestContainer.getFirstMappedPort();
}
public getMappedPort(port: number, protocol?: string): number;
public getMappedPort(portWithProtocol: `${number}/${"tcp" | "udp"}`): number;
public getMappedPort(port: number | `${number}/${"tcp" | "udp"}`, protocol?: string): number {
if (typeof port === "number") {
return this.startedTestContainer.getMappedPort(port, protocol);
}
return this.startedTestContainer.getMappedPort(port);
}
public getName(): string {
return this.startedTestContainer.getName();
}
public getLabels(): Labels {
return this.startedTestContainer.getLabels();
}
public getId(): string {
return this.startedTestContainer.getId();
}
public getNetworkNames(): string[] {
return this.startedTestContainer.getNetworkNames();
}
public getNetworkId(networkName: string): string {
return this.startedTestContainer.getNetworkId(networkName);
}
public getIpAddress(networkName: string): string {
return this.startedTestContainer.getIpAddress(networkName);
}
public async copyFilesToContainer(filesToCopy: FileToCopy[]): Promise<void> {
return this.startedTestContainer.copyFilesToContainer(filesToCopy);
}
public async copyDirectoriesToContainer(directoriesToCopy: DirectoryToCopy[]): Promise<void> {
return this.startedTestContainer.copyDirectoriesToContainer(directoriesToCopy);
}
public async copyContentToContainer(contentsToCopy: ContentToCopy[]): Promise<void> {
return this.startedTestContainer.copyContentToContainer(contentsToCopy);
}
public copyArchiveToContainer(tar: Readable, target = "/"): Promise<void> {
return this.startedTestContainer.copyArchiveToContainer(tar, target);
}
public copyArchiveFromContainer(path: string): Promise<NodeJS.ReadableStream> {
return this.startedTestContainer.copyArchiveFromContainer(path);
}
public exec(command: string | string[], opts?: Partial<ExecOptions>): Promise<ExecResult> {
return this.startedTestContainer.exec(command, opts);
}
public logs(opts?: { since?: number; tail?: number }): Promise<Readable> {
return this.startedTestContainer.logs(opts);
}
async [Symbol.asyncDispose]() {
await this.stop();
}
}