You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ EventSourcingDB enables you to build and operate event-driven applications with
6
6
7
7
For more information on EventSourcingDB, see its [official documentation](https://docs.eventsourcingdb.io/).
8
8
9
+
This client SDK includes support for [Testcontainers](https://testcontainers.com/) to spin up EventSourcingDB instances in integration tests. For details, see [Using Testcontainers](#using-testcontainers).
10
+
9
11
## Getting Started
10
12
11
13
Import the `Client` class and create an instance by providing the URL of your EventSourcingDB instance and the API token to use:
@@ -356,3 +358,52 @@ for await (const eventType of client.readEventTypes()) {
356
358
// reading to end.
357
359
controller.abort();
358
360
```
361
+
362
+
### Using Testcontainers
363
+
364
+
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:
To check if the test container is running, call the `isRunning` function:
380
+
381
+
```typescript
382
+
const isRunning =container.isRunning();
383
+
```
384
+
385
+
#### Configuring the Container Instance
386
+
387
+
By default, `EventSourcingDbContainer` uses the `latest` tag of the official EventSourcingDB Docker image. To change that, call the `withImageTag` function:
388
+
389
+
```typescript
390
+
const container =newEventSourcingDbContainer()
391
+
.withImageTag('1.0.0');
392
+
```
393
+
394
+
Similarly, you can configure the port to use and the API token. Call the `withPort` or the `withApiToken` function respectively:
395
+
396
+
```typescript
397
+
const container =newEventSourcingDbContainer()
398
+
.withPort(4000)
399
+
.withApiToken('secret');
400
+
```
401
+
402
+
#### Configuring the Client Manually
403
+
404
+
In case you need to set up the client yourself, use the following functions to get details on the container:
405
+
406
+
-`getHost()` returns the host name.
407
+
-`getMappedPort()` returns the port.
408
+
-`getBaseUrl()` returns the full URL of the container.
0 commit comments