forked from testcontainers/testcontainers-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstract-started-container.test.ts
More file actions
41 lines (34 loc) · 1.2 KB
/
abstract-started-container.test.ts
File metadata and controls
41 lines (34 loc) · 1.2 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
import { Mock } from "vitest";
import { AbstractStartedContainer, GenericContainer } from "../index";
describe.sequential("AbstractStartedContainer", { timeout: 60_000 }, () => {
let containerStopping: Mock;
let containerStopped: Mock;
beforeEach(() => {
containerStopping = vi.fn();
containerStopped = vi.fn();
});
it("should call overridden lifecycle methods when disposing asynchronously", async () => {
{
await using _container = await new CustomContainerWithCustomStartedContainer(
"cristianrgreco/testcontainer:1.1.14"
)
.withExposedPorts(8080)
.start();
}
expect(containerStopping).toHaveBeenCalled();
expect(containerStopped).toHaveBeenCalled();
});
class CustomContainerWithCustomStartedContainer extends GenericContainer {
public override async start(): Promise<CustomStartedContainer> {
return new CustomStartedContainer(await super.start());
}
}
class CustomStartedContainer extends AbstractStartedContainer {
protected override async containerStopping(): Promise<void> {
containerStopping();
}
protected override async containerStopped(): Promise<void> {
containerStopped();
}
}
});