@event-driven-io/emmett-testcontainers 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eventStore/eventStoreDBContainer.d.mts +15 -0
- package/dist/eventStore/eventStoreDBContainer.d.ts +15 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.d.mts +2 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.d.ts +2 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.js +26 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.js.map +1 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.mjs +26 -0
- package/dist/eventStore/eventStoreDBContainer.e2e.spec.mjs.map +1 -0
- package/dist/eventStore/eventStoreDBContainer.js +58 -0
- package/dist/eventStore/eventStoreDBContainer.js.map +1 -0
- package/dist/eventStore/eventStoreDBContainer.mjs +58 -0
- package/dist/eventStore/eventStoreDBContainer.mjs.map +1 -0
- package/dist/eventStore/index.d.mts +5 -0
- package/dist/eventStore/index.d.ts +5 -0
- package/dist/eventStore/index.js +21 -0
- package/dist/eventStore/index.js.map +1 -0
- package/dist/eventStore/index.mjs +21 -0
- package/dist/eventStore/index.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventStoreDBClient } from '@eventstore/db-client';
|
|
2
|
+
import { GenericContainer, AbstractStartedContainer, StartedTestContainer } from 'testcontainers';
|
|
3
|
+
|
|
4
|
+
declare class EventStoreDBContainer extends GenericContainer {
|
|
5
|
+
private readonly tcpPorts;
|
|
6
|
+
constructor(image?: string, runProjections?: boolean, isInsecure?: boolean, emptyDatabase?: boolean, withoutReuse?: boolean);
|
|
7
|
+
start(): Promise<StartedEventStoreDBContainer>;
|
|
8
|
+
}
|
|
9
|
+
declare class StartedEventStoreDBContainer extends AbstractStartedContainer {
|
|
10
|
+
constructor(container: StartedTestContainer);
|
|
11
|
+
getConnectionString(): string;
|
|
12
|
+
getClient(): EventStoreDBClient;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { EventStoreDBContainer, StartedEventStoreDBContainer };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventStoreDBClient } from '@eventstore/db-client';
|
|
2
|
+
import { GenericContainer, AbstractStartedContainer, StartedTestContainer } from 'testcontainers';
|
|
3
|
+
|
|
4
|
+
declare class EventStoreDBContainer extends GenericContainer {
|
|
5
|
+
private readonly tcpPorts;
|
|
6
|
+
constructor(image?: string, runProjections?: boolean, isInsecure?: boolean, emptyDatabase?: boolean, withoutReuse?: boolean);
|
|
7
|
+
start(): Promise<StartedEventStoreDBContainer>;
|
|
8
|
+
}
|
|
9
|
+
declare class StartedEventStoreDBContainer extends AbstractStartedContainer {
|
|
10
|
+
constructor(container: StartedTestContainer);
|
|
11
|
+
getConnectionString(): string;
|
|
12
|
+
getClient(): EventStoreDBClient;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { EventStoreDBContainer, StartedEventStoreDBContainer };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _dbclient = require('@eventstore/db-client');
|
|
2
|
+
var _strict = require('node:assert/strict'); var _strict2 = _interopRequireDefault(_strict);
|
|
3
|
+
var _nodetest = require('node:test');
|
|
4
|
+
var _uuid = require('uuid');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _eventStoreDBContainer = require('./eventStoreDBContainer');
|
|
9
|
+
_nodetest.describe.call(void 0, "EventStoreDBContainer", () => {
|
|
10
|
+
let container;
|
|
11
|
+
_nodetest.beforeEach.call(void 0, async () => {
|
|
12
|
+
container = await new (0, _eventStoreDBContainer.EventStoreDBContainer)().start();
|
|
13
|
+
});
|
|
14
|
+
_nodetest.it.call(void 0, "should connect to EventStoreDB and append new event", async () => {
|
|
15
|
+
const client = container.getClient();
|
|
16
|
+
const result = await client.appendToStream(
|
|
17
|
+
`test-${_uuid.v4.call(void 0, )}`,
|
|
18
|
+
_dbclient.jsonEvent.call(void 0, { type: "test-event", data: { test: "test" } })
|
|
19
|
+
);
|
|
20
|
+
_strict2.default.ok(result.success);
|
|
21
|
+
});
|
|
22
|
+
_nodetest.after.call(void 0, async () => {
|
|
23
|
+
await container.stop();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=eventStoreDBContainer.e2e.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/eventStoreDBContainer.e2e.spec.ts"],"names":[],"mappings":"AACA,SAAS,iBAAiB;AAC1B,OAAO,YAAY;AACnB,SAAS,OAAO,YAAY,UAAU,UAAU;AAChD,SAAS,MAAM,YAAY;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB,MAAM;AACtC,MAAI;AAEJ,aAAW,YAAY;AACrB,gBAAY,MAAM,IAAI,sBAAsB,EAAE,MAAM;AAAA,EACtD,CAAC;AAED,KAAG,uDAAuD,YAAY;AACpE,UAAM,SAAS,UAAU,UAAU;AAEnC,UAAM,SAAS,MAAM,OAAO;AAAA,MAC1B,QAAQ,KAAK,CAAC;AAAA,MACd,UAAU,EAAE,MAAM,cAAc,MAAM,EAAE,MAAM,OAAO,EAAE,CAAC;AAAA,IAC1D;AAEA,WAAO,GAAG,OAAO,OAAO;AAAA,EAC1B,CAAC;AAED,QAAM,YAAY;AAChB,UAAM,UAAU,KAAK;AAAA,EACvB,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-floating-promises */\nimport { jsonEvent } from '@eventstore/db-client';\nimport assert from 'node:assert/strict';\nimport { after, beforeEach, describe, it } from 'node:test';\nimport { v4 as uuid } from 'uuid';\nimport {\n EventStoreDBContainer,\n StartedEventStoreDBContainer,\n} from './eventStoreDBContainer';\n\ndescribe('EventStoreDBContainer', () => {\n let container: StartedEventStoreDBContainer;\n\n beforeEach(async () => {\n container = await new EventStoreDBContainer().start();\n });\n\n it('should connect to EventStoreDB and append new event', async () => {\n const client = container.getClient();\n\n const result = await client.appendToStream(\n `test-${uuid()}`,\n jsonEvent({ type: 'test-event', data: { test: 'test' } }),\n );\n\n assert.ok(result.success);\n });\n\n after(async () => {\n await container.stop();\n });\n});\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsonEvent } from "@eventstore/db-client";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { after, beforeEach, describe, it } from "node:test";
|
|
4
|
+
import { v4 as uuid } from "uuid";
|
|
5
|
+
import {
|
|
6
|
+
EventStoreDBContainer,
|
|
7
|
+
StartedEventStoreDBContainer
|
|
8
|
+
} from "./eventStoreDBContainer";
|
|
9
|
+
describe("EventStoreDBContainer", () => {
|
|
10
|
+
let container;
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
container = await new EventStoreDBContainer().start();
|
|
13
|
+
});
|
|
14
|
+
it("should connect to EventStoreDB and append new event", async () => {
|
|
15
|
+
const client = container.getClient();
|
|
16
|
+
const result = await client.appendToStream(
|
|
17
|
+
`test-${uuid()}`,
|
|
18
|
+
jsonEvent({ type: "test-event", data: { test: "test" } })
|
|
19
|
+
);
|
|
20
|
+
assert.ok(result.success);
|
|
21
|
+
});
|
|
22
|
+
after(async () => {
|
|
23
|
+
await container.stop();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=eventStoreDBContainer.e2e.spec.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/eventStoreDBContainer.e2e.spec.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-floating-promises */\nimport { jsonEvent } from '@eventstore/db-client';\nimport assert from 'node:assert/strict';\nimport { after, beforeEach, describe, it } from 'node:test';\nimport { v4 as uuid } from 'uuid';\nimport {\n EventStoreDBContainer,\n StartedEventStoreDBContainer,\n} from './eventStoreDBContainer';\n\ndescribe('EventStoreDBContainer', () => {\n let container: StartedEventStoreDBContainer;\n\n beforeEach(async () => {\n container = await new EventStoreDBContainer().start();\n });\n\n it('should connect to EventStoreDB and append new event', async () => {\n const client = container.getClient();\n\n const result = await client.appendToStream(\n `test-${uuid()}`,\n jsonEvent({ type: 'test-event', data: { test: 'test' } }),\n );\n\n assert.ok(result.success);\n });\n\n after(async () => {\n await container.stop();\n });\n});\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,OAAO,YAAY;AACnB,SAAS,OAAO,YAAY,UAAU,UAAU;AAChD,SAAS,MAAM,YAAY;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB,MAAM;AACtC,MAAI;AAEJ,aAAW,YAAY;AACrB,gBAAY,MAAM,IAAI,sBAAsB,EAAE,MAAM;AAAA,EACtD,CAAC;AAED,KAAG,uDAAuD,YAAY;AACpE,UAAM,SAAS,UAAU,UAAU;AAEnC,UAAM,SAAS,MAAM,OAAO;AAAA,MAC1B,QAAQ,KAAK,CAAC;AAAA,MACd,UAAU,EAAE,MAAM,cAAc,MAAM,EAAE,MAAM,OAAO,EAAE,CAAC;AAAA,IAC1D;AAEA,WAAO,GAAG,OAAO,OAAO;AAAA,EAC1B,CAAC;AAED,QAAM,YAAY;AAChB,UAAM,UAAU,KAAK;AAAA,EACvB,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _dbclient = require('@eventstore/db-client');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _testcontainers = require('testcontainers');
|
|
6
|
+
const EVENTSTOREDB_PORT = 2113;
|
|
7
|
+
const EVENTSTOREDB_TCP_PORT = 1113;
|
|
8
|
+
const EVENTSTOREDB_TCP_PORTS = [EVENTSTOREDB_TCP_PORT, EVENTSTOREDB_PORT];
|
|
9
|
+
const EVENTSTOREDB_IMAGE_NAME = "eventstore/eventstore";
|
|
10
|
+
const EVENTSTOREDB_IMAGE_TAG = "23.10.1-bookworm-slim";
|
|
11
|
+
class EventStoreDBContainer extends _testcontainers.GenericContainer {
|
|
12
|
+
__init() {this.tcpPorts = EVENTSTOREDB_TCP_PORTS}
|
|
13
|
+
constructor(image = `${EVENTSTOREDB_IMAGE_NAME}:${EVENTSTOREDB_IMAGE_TAG}`, runProjections = true, isInsecure = true, emptyDatabase = true, withoutReuse = false) {
|
|
14
|
+
super(image);EventStoreDBContainer.prototype.__init.call(this);;
|
|
15
|
+
const environment = {
|
|
16
|
+
...runProjections ? {
|
|
17
|
+
EVENTSTORE_RUN_PROJECTIONS: "ALL"
|
|
18
|
+
} : {},
|
|
19
|
+
...isInsecure ? {
|
|
20
|
+
EVENTSTORE_INSECURE: "true"
|
|
21
|
+
} : {},
|
|
22
|
+
...!emptyDatabase ? {
|
|
23
|
+
EVENTSTORE_MEM_DB: "false",
|
|
24
|
+
EVENTSTORE_DB: "/data/integration-tests"
|
|
25
|
+
} : {},
|
|
26
|
+
EVENTSTORE_CLUSTER_SIZE: "1",
|
|
27
|
+
EVENTSTORE_START_STANDARD_PROJECTIONS: "true",
|
|
28
|
+
EVENTSTORE_EXT_TCP_PORT: `${EVENTSTOREDB_TCP_PORT}`,
|
|
29
|
+
EVENTSTORE_HTTP_PORT: `${EVENTSTOREDB_PORT}`,
|
|
30
|
+
EVENTSTORE_ENABLE_EXTERNAL_TCP: "true",
|
|
31
|
+
EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: "true"
|
|
32
|
+
};
|
|
33
|
+
this.withEnvironment(environment).withExposedPorts(...this.tcpPorts);
|
|
34
|
+
if (!withoutReuse)
|
|
35
|
+
this.withReuse();
|
|
36
|
+
}
|
|
37
|
+
async start() {
|
|
38
|
+
return new StartedEventStoreDBContainer(await super.start());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class StartedEventStoreDBContainer extends _testcontainers.AbstractStartedContainer {
|
|
42
|
+
constructor(container) {
|
|
43
|
+
super(container);
|
|
44
|
+
}
|
|
45
|
+
getConnectionString() {
|
|
46
|
+
return `esdb://${this.getHost()}:${this.getMappedPort(
|
|
47
|
+
2113
|
|
48
|
+
)}?tls=false&throwOnAppendFailure=false`;
|
|
49
|
+
}
|
|
50
|
+
getClient() {
|
|
51
|
+
return _dbclient.EventStoreDBClient.connectionString(this.getConnectionString());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
exports.EventStoreDBContainer = EventStoreDBContainer; exports.StartedEventStoreDBContainer = StartedEventStoreDBContainer;
|
|
58
|
+
//# sourceMappingURL=eventStoreDBContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/eventStoreDBContainer.ts"],"names":[],"mappings":"AAAA,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAGP,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB,CAAC,uBAAuB,iBAAiB;AACxE,MAAM,0BAA0B;AAChC,MAAM,yBAAyB;AAExB,MAAM,8BAA8B,iBAAiB;AAAA,EACzC,WAAW;AAAA,EAE5B,YACE,QAAQ,GAAG,uBAAuB,IAAI,sBAAsB,IAC5D,iBAAiB,MACjB,aAAa,MACb,gBAAgB,MAChB,eAAe,OACf;AACA,UAAM,KAAK;AAEX,UAAM,cAA2B;AAAA,MAC/B,GAAI,iBACA;AAAA,QACE,4BAA4B;AAAA,MAC9B,IACA,CAAC;AAAA,MACL,GAAI,aACA;AAAA,QACE,qBAAqB;AAAA,MACvB,IACA,CAAC;AAAA,MACL,GAAI,CAAC,gBACD;AAAA,QACE,mBAAmB;AAAA,QACnB,eAAe;AAAA,MACjB,IACA,CAAC;AAAA,MACL,yBAAyB;AAAA,MACzB,uCAAuC;AAAA,MACvC,yBAAyB,GAAG,qBAAqB;AAAA,MACjD,sBAAsB,GAAG,iBAAiB;AAAA,MAC1C,gCAAgC;AAAA,MAChC,sCAAsC;AAAA,IACxC;AAEA,SAAK,gBAAgB,WAAW,EAAE,iBAAiB,GAAG,KAAK,QAAQ;AAEnE,QAAI,CAAC;AAAc,WAAK,UAAU;AAAA,EACpC;AAAA,EAEA,MAAM,QAA+C;AACnD,WAAO,IAAI,6BAA6B,MAAM,MAAM,MAAM,CAAC;AAAA,EAC7D;AACF;AAEO,MAAM,qCAAqC,yBAAyB;AAAA,EACzE,YAAY,WAAiC;AAC3C,UAAM,SAAS;AAAA,EACjB;AAAA,EAEA,sBAA8B;AAC5B,WAAO,UAAU,KAAK,QAAQ,CAAC,IAAI,KAAK;AAAA,MACtC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,YAAgC;AAC9B,WAAO,mBAAmB,iBAAiB,KAAK,oBAAoB,CAAC;AAAA,EACvE;AACF","sourcesContent":["import { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nconst EVENTSTOREDB_PORT = 2113;\nconst EVENTSTOREDB_TCP_PORT = 1113;\nconst EVENTSTOREDB_TCP_PORTS = [EVENTSTOREDB_TCP_PORT, EVENTSTOREDB_PORT];\nconst EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nconst EVENTSTOREDB_IMAGE_TAG = '23.10.1-bookworm-slim';\n\nexport class EventStoreDBContainer extends GenericContainer {\n private readonly tcpPorts = EVENTSTOREDB_TCP_PORTS;\n\n constructor(\n image = `${EVENTSTOREDB_IMAGE_NAME}:${EVENTSTOREDB_IMAGE_TAG}`,\n runProjections = true,\n isInsecure = true,\n emptyDatabase = true,\n withoutReuse = false,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(runProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(isInsecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(!emptyDatabase\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_EXT_TCP_PORT: `${EVENTSTOREDB_TCP_PORT}`,\n EVENTSTORE_HTTP_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_EXTERNAL_TCP: 'true',\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(...this.tcpPorts);\n\n if (!withoutReuse) this.withReuse();\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(\n 2113,\n )}?tls=false&throwOnAppendFailure=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EventStoreDBClient } from "@eventstore/db-client";
|
|
2
|
+
import {
|
|
3
|
+
AbstractStartedContainer,
|
|
4
|
+
GenericContainer
|
|
5
|
+
} from "testcontainers";
|
|
6
|
+
const EVENTSTOREDB_PORT = 2113;
|
|
7
|
+
const EVENTSTOREDB_TCP_PORT = 1113;
|
|
8
|
+
const EVENTSTOREDB_TCP_PORTS = [EVENTSTOREDB_TCP_PORT, EVENTSTOREDB_PORT];
|
|
9
|
+
const EVENTSTOREDB_IMAGE_NAME = "eventstore/eventstore";
|
|
10
|
+
const EVENTSTOREDB_IMAGE_TAG = "23.10.1-bookworm-slim";
|
|
11
|
+
class EventStoreDBContainer extends GenericContainer {
|
|
12
|
+
tcpPorts = EVENTSTOREDB_TCP_PORTS;
|
|
13
|
+
constructor(image = `${EVENTSTOREDB_IMAGE_NAME}:${EVENTSTOREDB_IMAGE_TAG}`, runProjections = true, isInsecure = true, emptyDatabase = true, withoutReuse = false) {
|
|
14
|
+
super(image);
|
|
15
|
+
const environment = {
|
|
16
|
+
...runProjections ? {
|
|
17
|
+
EVENTSTORE_RUN_PROJECTIONS: "ALL"
|
|
18
|
+
} : {},
|
|
19
|
+
...isInsecure ? {
|
|
20
|
+
EVENTSTORE_INSECURE: "true"
|
|
21
|
+
} : {},
|
|
22
|
+
...!emptyDatabase ? {
|
|
23
|
+
EVENTSTORE_MEM_DB: "false",
|
|
24
|
+
EVENTSTORE_DB: "/data/integration-tests"
|
|
25
|
+
} : {},
|
|
26
|
+
EVENTSTORE_CLUSTER_SIZE: "1",
|
|
27
|
+
EVENTSTORE_START_STANDARD_PROJECTIONS: "true",
|
|
28
|
+
EVENTSTORE_EXT_TCP_PORT: `${EVENTSTOREDB_TCP_PORT}`,
|
|
29
|
+
EVENTSTORE_HTTP_PORT: `${EVENTSTOREDB_PORT}`,
|
|
30
|
+
EVENTSTORE_ENABLE_EXTERNAL_TCP: "true",
|
|
31
|
+
EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: "true"
|
|
32
|
+
};
|
|
33
|
+
this.withEnvironment(environment).withExposedPorts(...this.tcpPorts);
|
|
34
|
+
if (!withoutReuse)
|
|
35
|
+
this.withReuse();
|
|
36
|
+
}
|
|
37
|
+
async start() {
|
|
38
|
+
return new StartedEventStoreDBContainer(await super.start());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class StartedEventStoreDBContainer extends AbstractStartedContainer {
|
|
42
|
+
constructor(container) {
|
|
43
|
+
super(container);
|
|
44
|
+
}
|
|
45
|
+
getConnectionString() {
|
|
46
|
+
return `esdb://${this.getHost()}:${this.getMappedPort(
|
|
47
|
+
2113
|
|
48
|
+
)}?tls=false&throwOnAppendFailure=false`;
|
|
49
|
+
}
|
|
50
|
+
getClient() {
|
|
51
|
+
return EventStoreDBClient.connectionString(this.getConnectionString());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
EventStoreDBContainer,
|
|
56
|
+
StartedEventStoreDBContainer
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=eventStoreDBContainer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/eventStoreDBContainer.ts"],"sourcesContent":["import { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nconst EVENTSTOREDB_PORT = 2113;\nconst EVENTSTOREDB_TCP_PORT = 1113;\nconst EVENTSTOREDB_TCP_PORTS = [EVENTSTOREDB_TCP_PORT, EVENTSTOREDB_PORT];\nconst EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nconst EVENTSTOREDB_IMAGE_TAG = '23.10.1-bookworm-slim';\n\nexport class EventStoreDBContainer extends GenericContainer {\n private readonly tcpPorts = EVENTSTOREDB_TCP_PORTS;\n\n constructor(\n image = `${EVENTSTOREDB_IMAGE_NAME}:${EVENTSTOREDB_IMAGE_TAG}`,\n runProjections = true,\n isInsecure = true,\n emptyDatabase = true,\n withoutReuse = false,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(runProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(isInsecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(!emptyDatabase\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_EXT_TCP_PORT: `${EVENTSTOREDB_TCP_PORT}`,\n EVENTSTORE_HTTP_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_EXTERNAL_TCP: 'true',\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(...this.tcpPorts);\n\n if (!withoutReuse) this.withReuse();\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(\n 2113,\n )}?tls=false&throwOnAppendFailure=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAGP,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB,CAAC,uBAAuB,iBAAiB;AACxE,MAAM,0BAA0B;AAChC,MAAM,yBAAyB;AAExB,MAAM,8BAA8B,iBAAiB;AAAA,EACzC,WAAW;AAAA,EAE5B,YACE,QAAQ,GAAG,uBAAuB,IAAI,sBAAsB,IAC5D,iBAAiB,MACjB,aAAa,MACb,gBAAgB,MAChB,eAAe,OACf;AACA,UAAM,KAAK;AAEX,UAAM,cAA2B;AAAA,MAC/B,GAAI,iBACA;AAAA,QACE,4BAA4B;AAAA,MAC9B,IACA,CAAC;AAAA,MACL,GAAI,aACA;AAAA,QACE,qBAAqB;AAAA,MACvB,IACA,CAAC;AAAA,MACL,GAAI,CAAC,gBACD;AAAA,QACE,mBAAmB;AAAA,QACnB,eAAe;AAAA,MACjB,IACA,CAAC;AAAA,MACL,yBAAyB;AAAA,MACzB,uCAAuC;AAAA,MACvC,yBAAyB,GAAG,qBAAqB;AAAA,MACjD,sBAAsB,GAAG,iBAAiB;AAAA,MAC1C,gCAAgC;AAAA,MAChC,sCAAsC;AAAA,IACxC;AAEA,SAAK,gBAAgB,WAAW,EAAE,iBAAiB,GAAG,KAAK,QAAQ;AAEnE,QAAI,CAAC;AAAc,WAAK,UAAU;AAAA,EACpC;AAAA,EAEA,MAAM,QAA+C;AACnD,WAAO,IAAI,6BAA6B,MAAM,MAAM,MAAM,CAAC;AAAA,EAC7D;AACF;AAEO,MAAM,qCAAqC,yBAAyB;AAAA,EACzE,YAAY,WAAiC;AAC3C,UAAM,SAAS;AAAA,EACjB;AAAA,EAEA,sBAA8B;AAC5B,WAAO,UAAU,KAAK,QAAQ,CAAC,IAAI,KAAK;AAAA,MACtC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,YAAgC;AAC9B,WAAO,mBAAmB,iBAAiB,KAAK,oBAAoB,CAAC;AAAA,EACvE;AACF;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _dbclient = require('@eventstore/db-client');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _eventStoreDBContainer = require('./eventStoreDBContainer');
|
|
6
|
+
let esdbContainer;
|
|
7
|
+
const getEventStoreDBTestClient = async (useTestContainers = false) => {
|
|
8
|
+
let connectionString;
|
|
9
|
+
if (useTestContainers) {
|
|
10
|
+
if (!esdbContainer)
|
|
11
|
+
esdbContainer = await new (0, _eventStoreDBContainer.EventStoreDBContainer)().start();
|
|
12
|
+
connectionString = esdbContainer.getConnectionString();
|
|
13
|
+
} else {
|
|
14
|
+
connectionString = "esdb://localhost:2113?tls=false";
|
|
15
|
+
}
|
|
16
|
+
return _dbclient.EventStoreDBClient.connectionString(connectionString);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.getEventStoreDBTestClient = getEventStoreDBTestClient;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/index.ts"],"names":[],"mappings":"AAAA,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAI;AAEG,MAAM,4BAA4B,OACvC,oBAAoB,UACY;AAChC,MAAI;AAEJ,MAAI,mBAAmB;AACrB,QAAI,CAAC;AACH,sBAAgB,MAAM,IAAI,sBAAsB,EAAE,MAAM;AAE1D,uBAAmB,cAAc,oBAAoB;AAAA,EACvD,OAAO;AAEL,uBAAmB;AAAA,EACrB;AAIA,SAAO,mBAAmB,iBAAiB,gBAAgB;AAC7D","sourcesContent":["import { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n EventStoreDBContainer,\n StartedEventStoreDBContainer,\n} from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EventStoreDBClient } from "@eventstore/db-client";
|
|
2
|
+
import {
|
|
3
|
+
EventStoreDBContainer,
|
|
4
|
+
StartedEventStoreDBContainer
|
|
5
|
+
} from "./eventStoreDBContainer";
|
|
6
|
+
let esdbContainer;
|
|
7
|
+
const getEventStoreDBTestClient = async (useTestContainers = false) => {
|
|
8
|
+
let connectionString;
|
|
9
|
+
if (useTestContainers) {
|
|
10
|
+
if (!esdbContainer)
|
|
11
|
+
esdbContainer = await new EventStoreDBContainer().start();
|
|
12
|
+
connectionString = esdbContainer.getConnectionString();
|
|
13
|
+
} else {
|
|
14
|
+
connectionString = "esdb://localhost:2113?tls=false";
|
|
15
|
+
}
|
|
16
|
+
return EventStoreDBClient.connectionString(connectionString);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
getEventStoreDBTestClient
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eventStore/index.ts"],"sourcesContent":["import { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n EventStoreDBContainer,\n StartedEventStoreDBContainer,\n} from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n"],"mappings":"AAAA,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAI;AAEG,MAAM,4BAA4B,OACvC,oBAAoB,UACY;AAChC,MAAI;AAEJ,MAAI,mBAAmB;AACrB,QAAI,CAAC;AACH,sBAAgB,MAAM,IAAI,sBAAsB,EAAE,MAAM;AAE1D,uBAAmB,cAAc,oBAAoB;AAAA,EACvD,OAAO;AAEL,uBAAmB;AAAA,EACrB;AAIA,SAAO,mBAAmB,iBAAiB,gBAAgB;AAC7D;","names":[]}
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _eventStore = require('./eventStore'); _createStarExport(_eventStore);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc","sourcesContent":["export * from './eventStore';\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './eventStore';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@event-driven-io/emmett-testcontainers",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Emmett - TestContainers - Event Sourcing development made simple",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsup",
|
|
7
|
+
"build:ts": "tsc",
|
|
8
|
+
"build:ts:watch": "tsc --watch",
|
|
9
|
+
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
10
|
+
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
|
|
11
|
+
"lint:eslint": "eslint **/*.ts",
|
|
12
|
+
"fix": "run-s fix:eslint fix:prettier",
|
|
13
|
+
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
|
|
14
|
+
"fix:eslint": "eslint **/*.ts --fix",
|
|
15
|
+
"test": "run-s test:unit test:int test:e2e",
|
|
16
|
+
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
|
|
17
|
+
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
|
|
18
|
+
"test:e2e": "glob -c \"node --import tsx --test\" **/*.e2e.spec.ts",
|
|
19
|
+
"test:watch": "node --import tsx --test --watch",
|
|
20
|
+
"test:unit:watch": "glob -c \"node --import tsx --test --watch\" **/*.unit.spec.ts",
|
|
21
|
+
"test:int:watch": "glob -c \"node --import tsx --test --watch\" **/*.int.spec.ts",
|
|
22
|
+
"test:e2e:watch": "glob -c \"node --import tsx --test --watch\" **/*.e2e.spec.ts"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/event-driven-io/emmett.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"Event Sourcing"
|
|
30
|
+
],
|
|
31
|
+
"author": "Oskar Dudycz",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/event-driven-io/emmett/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://event-driven-io.github.io/emmett/",
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"module": "./dist/index.mjs",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@event-driven-io/emmett": "0.3.0",
|
|
44
|
+
"testcontainers": "^10.7.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@eventstore/db-client": "^6.1.0"
|
|
48
|
+
}
|
|
49
|
+
}
|