diff --git a/README.md b/README.md index a029301..d5d911c 100644 --- a/README.md +++ b/README.md @@ -403,12 +403,12 @@ controller.abort(); ### Using Testcontainers -Import the `EventSourcingDbContainer` class, create an instance, call the `start` function to run a test container, get a client, run your test code, and finally call the `stop` function to stop the test container: +Import the `Container` class, create an instance, call the `start` function to run a test container, get a client, run your test code, and finally call the `stop` function to stop the test container: ```typescript -import { EventSourcingDbContainer } from 'eventsourcingdb'; +import { Container } from 'eventsourcingdb'; -const container = new EventSourcingDbContainer(); +const container = new Container(); await container.start(); const client = container.getClient(); @@ -426,17 +426,17 @@ const isRunning = container.isRunning(); #### Configuring the Container Instance -By default, `EventSourcingDbContainer` uses the `latest` tag of the official EventSourcingDB Docker image. To change that, call the `withImageTag` function: +By default, `Container` uses the `latest` tag of the official EventSourcingDB Docker image. To change that, call the `withImageTag` function: ```typescript -const container = new EventSourcingDbContainer() +const container = new Container() .withImageTag('1.0.0'); ``` Similarly, you can configure the port to use and the API token. Call the `withPort` or the `withApiToken` function respectively: ```typescript -const container = new EventSourcingDbContainer() +const container = new Container() .withPort(4000) .withApiToken('secret'); ``` diff --git a/src/EventSourcingDbContainer.ts b/src/Container.ts similarity index 96% rename from src/EventSourcingDbContainer.ts rename to src/Container.ts index cd8e5e2..4f13f7a 100644 --- a/src/EventSourcingDbContainer.ts +++ b/src/Container.ts @@ -2,7 +2,7 @@ import type { StartedTestContainer } from 'testcontainers'; import { GenericContainer, Wait } from 'testcontainers'; import { Client } from './Client.js'; -class EventSourcingDbContainer { +class Container { #imageName = 'thenativeweb/eventsourcingdb'; #imageTag = 'latest'; #internalPort = 3000; @@ -88,4 +88,4 @@ class EventSourcingDbContainer { } } -export { EventSourcingDbContainer }; +export { Container }; diff --git a/src/index.ts b/src/index.ts index 41193f6..eade594 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,12 @@ import { Client } from './Client.js'; +import { Container } from './Container.js'; import type { Event } from './Event.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import type { EventType } from './EventType.js'; import type { ObserveEventsOptions } from './ObserveEventsOptions.js'; import type { ReadEventsOptions } from './ReadEventsOptions.js'; import { isSubjectOnEventId } from './isSubjectOnEventId.js'; import { isSubjectPristine } from './isSubjectPristine.js'; -export { Client, EventSourcingDbContainer, isSubjectPristine, isSubjectOnEventId }; +export { Client, Container, isSubjectPristine, isSubjectOnEventId }; export type { Event, EventCandidate, EventType, ReadEventsOptions, ObserveEventsOptions }; diff --git a/src/observeEvents.test.ts b/src/observeEvents.test.ts index 1fcaf36..fb895cd 100644 --- a/src/observeEvents.test.ts +++ b/src/observeEvents.test.ts @@ -1,16 +1,16 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { Event } from './Event.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('observeEvents', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/ping.test.ts b/src/ping.test.ts index 45ef3dc..e066409 100644 --- a/src/ping.test.ts +++ b/src/ping.test.ts @@ -1,15 +1,15 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; import { Client } from './Client.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; +import { Container } from './Container.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('ping', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/readEventTypes.test.ts b/src/readEventTypes.test.ts index d5601e5..d567f79 100644 --- a/src/readEventTypes.test.ts +++ b/src/readEventTypes.test.ts @@ -1,16 +1,16 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import type { EventType } from './EventType.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('readEventTypes', { timeout: 20_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/readEvents.test.ts b/src/readEvents.test.ts index fcc3c29..59fd6e1 100644 --- a/src/readEvents.test.ts +++ b/src/readEvents.test.ts @@ -1,16 +1,16 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { Event } from './Event.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('readEvents', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/readSubjects.test.ts b/src/readSubjects.test.ts index 3a7a384..710677d 100644 --- a/src/readSubjects.test.ts +++ b/src/readSubjects.test.ts @@ -1,15 +1,15 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('readSubjects', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/registerEventSchema.test.ts b/src/registerEventSchema.test.ts index dff6a24..f1eb826 100644 --- a/src/registerEventSchema.test.ts +++ b/src/registerEventSchema.test.ts @@ -1,14 +1,14 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; +import { Container } from './Container.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('registerEventSchema', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/runEventQlQuery.test.ts b/src/runEventQlQuery.test.ts index a289557..b792040 100644 --- a/src/runEventQlQuery.test.ts +++ b/src/runEventQlQuery.test.ts @@ -1,15 +1,15 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('runEventQlQuery', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/verifyApiToken.test.ts b/src/verifyApiToken.test.ts index 06989c4..fec5f7f 100644 --- a/src/verifyApiToken.test.ts +++ b/src/verifyApiToken.test.ts @@ -1,15 +1,15 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; import { Client } from './Client.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; +import { Container } from './Container.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; suite('verifyApiToken', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); }); diff --git a/src/writeEvents.test.ts b/src/writeEvents.test.ts index b3f7f43..8b28ed2 100644 --- a/src/writeEvents.test.ts +++ b/src/writeEvents.test.ts @@ -1,17 +1,17 @@ import assert from 'node:assert/strict'; import { afterEach, beforeEach, suite, test } from 'node:test'; +import { Container } from './Container.js'; import type { EventCandidate } from './EventCandidate.js'; -import { EventSourcingDbContainer } from './EventSourcingDbContainer.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; import { isSubjectOnEventId } from './isSubjectOnEventId.js'; import { isSubjectPristine } from './isSubjectPristine.js'; suite('writeEvents', { timeout: 30_000 }, () => { - let container: EventSourcingDbContainer; + let container: Container; beforeEach(async () => { const imageVersion = getImageVersionFromDockerfile(); - container = new EventSourcingDbContainer().withImageTag(imageVersion); + container = new Container().withImageTag(imageVersion); await container.start(); });