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[] = [];