From fadd8a0b8ce832ee1f07cd63ff125acd74d078ef Mon Sep 17 00:00:00 2001 From: Golo Roden Date: Tue, 29 Sep 2026 08:50:13 +0200 Subject: [PATCH] fix: Pass the port of the test container on to EventSourcingDB. withPort changed the port that is mapped and probed, but EventSourcingDB kept listening on its default port 3000, so a container with a custom port never became ready. The port is now passed on via --http-port. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM --- src/Container.test.ts | 23 +++++++++++++++++++++++ src/Container.ts | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 src/Container.test.ts diff --git a/src/Container.test.ts b/src/Container.test.ts new file mode 100644 index 0000000..e7fcc52 --- /dev/null +++ b/src/Container.test.ts @@ -0,0 +1,23 @@ +import assert from 'node:assert/strict'; +import { suite, test } from 'node:test'; +import { Container } from './Container.js'; +import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; + +suite('Container', { timeout: 30_000 }, () => { + test('starts with a custom port.', async (): Promise => { + const imageVersion = getImageVersionFromDockerfile(); + const container = new Container().withImageTag(imageVersion).withPort(4000); + + await container.start(); + + try { + const client = container.getClient(); + + // Should not throw. + await client.ping(); + assert.ok(container.getMappedPort() > 0); + } finally { + await container.stop(); + } + }); +}); diff --git a/src/Container.ts b/src/Container.ts index bb1f093..889915c 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -46,6 +46,8 @@ class Container { '--data-directory-temporary', '--http-enabled', '--https-enabled=false', + '--http-port', + String(this.#internalPort), ]; const contents: ContentToCopy[] = [];