Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
```
Expand Down
4 changes: 2 additions & 2 deletions src/EventSourcingDbContainer.ts → src/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,4 +88,4 @@ class EventSourcingDbContainer {
}
}

export { EventSourcingDbContainer };
export { Container };
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
6 changes: 3 additions & 3 deletions src/observeEvents.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/ping.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/readEventTypes.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/readEvents.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/readSubjects.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/registerEventSchema.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/runEventQlQuery.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/verifyApiToken.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/writeEvents.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand Down