Skip to content

Commit 037f27e

Browse files
committed
fix tests for pr testcontainers#905
1 parent e413d81 commit 037f27e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/testcontainers/src/generic-container/generic-container.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,11 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
525525
.withAutoRemove(false)
526526
.start();
527527

528-
await container.stop();
529-
530-
expect(await getRunningContainerNames()).not.toContain(container.getName().replace("/", ""));
531-
expect(await getStoppedContainerNames()).toContain(container.getName().replace("/", ""));
528+
const stopped = await container.stop();
529+
const dockerode = (await getContainerRuntimeClient()).container.dockerode;
530+
expect(stopped.getId()).toBeTruthy();
531+
const lowerLevelContainer = dockerode.getContainer(stopped.getId());
532+
expect((await lowerLevelContainer.inspect()).State.Status).toEqual("exited");
532533
});
533534

534535
it("should stop and override .withAutoRemove", async () => {
@@ -539,8 +540,11 @@ describe("GenericContainer", { timeout: 180_000 }, () => {
539540

540541
await container.stop({ remove: true });
541542

542-
expect(await getRunningContainerNames()).not.toContain(container.getName().replace("/", ""));
543-
expect(await getStoppedContainerNames()).not.toContain(container.getName().replace("/", ""));
543+
const stopped = await container.stop();
544+
const dockerode = (await getContainerRuntimeClient()).container.dockerode;
545+
expect(stopped.getId()).toBeTruthy();
546+
const lowerLevelContainer = dockerode.getContainer(stopped.getId());
547+
await expect(lowerLevelContainer.inspect()).rejects.toThrow(/404/) // Error: (HTTP code 404) no such container
544548
});
545549

546550
it("should build a target stage", async () => {

0 commit comments

Comments
 (0)