@volontariapp/outbox 0.2.1 → 0.3.0-snap-78f0c89
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/CHANGELOG.md +6 -0
- package/dist/consumers/event-queue.consumer.d.ts +3 -1
- package/dist/consumers/event-queue.consumer.d.ts.map +1 -1
- package/dist/consumers/event-queue.consumer.js +4 -0
- package/dist/consumers/event-queue.consumer.js.map +1 -1
- package/dist/consumers/jobs-outbox.consumer.d.ts +3 -1
- package/dist/consumers/jobs-outbox.consumer.d.ts.map +1 -1
- package/dist/consumers/jobs-outbox.consumer.js +4 -0
- package/dist/consumers/jobs-outbox.consumer.js.map +1 -1
- package/dist/dispatchers/event-queue.dispatcher.d.ts +4 -0
- package/dist/dispatchers/event-queue.dispatcher.d.ts.map +1 -0
- package/dist/dispatchers/event-queue.dispatcher.js +4 -0
- package/dist/dispatchers/event-queue.dispatcher.js.map +1 -0
- package/dist/dispatchers/jobs-outbox.dispatcher.d.ts +4 -0
- package/dist/dispatchers/jobs-outbox.dispatcher.d.ts.map +1 -0
- package/dist/dispatchers/jobs-outbox.dispatcher.js +4 -0
- package/dist/dispatchers/jobs-outbox.dispatcher.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/test/consumers/event/event-queue.consumer.unit.spec.js +24 -1
- package/dist/test/consumers/event/event-queue.consumer.unit.spec.js.map +1 -1
- package/dist/test/consumers/jobs/jobs-outbox.consumer.unit.spec.js +24 -1
- package/dist/test/consumers/jobs/jobs-outbox.consumer.unit.spec.js.map +1 -1
- package/dist/test/dispatchers/event/event-queue.dispatcher.int.spec.d.ts +2 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.int.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.int.spec.js +77 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.int.spec.js.map +1 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.d.ts +2 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.js +42 -0
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.js.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.d.ts +2 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.js +80 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.js.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.d.ts +2 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.js +42 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.js.map +1 -0
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.d.ts +2 -2
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.js +2 -2
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.js.map +1 -1
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.d.ts +2 -2
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.js +2 -2
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.js.map +1 -1
- package/dist/test/utils/helpers/outbox-repository-mock.helper.d.ts +10 -0
- package/dist/test/utils/helpers/outbox-repository-mock.helper.d.ts.map +1 -0
- package/dist/test/utils/helpers/outbox-repository-mock.helper.js +10 -0
- package/dist/test/utils/helpers/outbox-repository-mock.helper.js.map +1 -0
- package/package.json +1 -1
- package/dist/test/utils/helpers/outbox-writer-mock.helper.d.ts +0 -10
- package/dist/test/utils/helpers/outbox-writer-mock.helper.d.ts.map +0 -1
- package/dist/test/utils/helpers/outbox-writer-mock.helper.js +0 -10
- package/dist/test/utils/helpers/outbox-writer-mock.helper.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
1
|
+
import type { BaseRepository, EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
2
2
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
3
|
+
import type { Logger } from '@volontariapp/logger';
|
|
3
4
|
export declare class EventQueueConsumer extends OutboxConsumer<EventQueueModel, EventQueueEntity> {
|
|
5
|
+
constructor(logger: Logger, repository: BaseRepository<EventQueueModel, EventQueueEntity, string>, batchSize: number);
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=event-queue.consumer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC;gBAErF,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,cAAc,CAAC,eAAe,EAAE,gBAAgB,EAAE,MAAM,CAAC,EACrE,SAAS,EAAE,MAAM;CAIpB"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
2
|
+
import { EventQueueDispatcher } from '../dispatchers/event-queue.dispatcher.js';
|
|
2
3
|
export class EventQueueConsumer extends OutboxConsumer {
|
|
4
|
+
constructor(logger, repository, batchSize) {
|
|
5
|
+
super(logger, repository, batchSize, new EventQueueDispatcher(logger, repository));
|
|
6
|
+
}
|
|
3
7
|
}
|
|
4
8
|
//# sourceMappingURL=event-queue.consumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.js","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,OAAO,kBAAmB,SAAQ,cAAiD;
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.js","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,MAAM,OAAO,kBAAmB,SAAQ,cAAiD;IACvF,YACE,MAAc,EACd,UAAqE,EACrE,SAAiB;QAEjB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
1
|
+
import type { BaseRepository, JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
2
2
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
3
|
+
import type { Logger } from '@volontariapp/logger';
|
|
3
4
|
export declare class JobsOutboxConsumer extends OutboxConsumer<JobsOutboxModel, JobsOutboxEntity> {
|
|
5
|
+
constructor(logger: Logger, repository: BaseRepository<JobsOutboxModel, JobsOutboxEntity, string>, batchSize: number);
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=jobs-outbox.consumer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC;gBAErF,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,cAAc,CAAC,eAAe,EAAE,gBAAgB,EAAE,MAAM,CAAC,EACrE,SAAS,EAAE,MAAM;CAIpB"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
2
|
+
import { JobsOutboxDispatcher } from '../dispatchers/jobs-outbox.dispatcher.js';
|
|
2
3
|
export class JobsOutboxConsumer extends OutboxConsumer {
|
|
4
|
+
constructor(logger, repository, batchSize) {
|
|
5
|
+
super(logger, repository, batchSize, new JobsOutboxDispatcher(logger, repository));
|
|
6
|
+
}
|
|
3
7
|
}
|
|
4
8
|
//# sourceMappingURL=jobs-outbox.consumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.js","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,OAAO,kBAAmB,SAAQ,cAAiD;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.js","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,MAAM,OAAO,kBAAmB,SAAQ,cAAiD;IACvF,YACE,MAAc,EACd,UAAqE,EACrE,SAAiB;QAEjB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,oBAAqB,SAAQ,gBAAgB,CAAC,eAAe,EAAE,gBAAgB,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,oBAAqB,SAAQ,gBAAmD;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,oBAAqB,SAAQ,gBAAgB,CAAC,eAAe,EAAE,gBAAgB,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,oBAAqB,SAAQ,gBAAmD;CAAG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from './writers/event-queue.writer.js';
|
|
|
2
2
|
export * from './writers/jobs-outbox.writer.js';
|
|
3
3
|
export * from './consumers/event-queue.consumer.js';
|
|
4
4
|
export * from './consumers/jobs-outbox.consumer.js';
|
|
5
|
+
export * from './dispatchers/event-queue.dispatcher.js';
|
|
6
|
+
export * from './dispatchers/jobs-outbox.dispatcher.js';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AAEpD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,6 @@ export * from './writers/event-queue.writer.js';
|
|
|
2
2
|
export * from './writers/jobs-outbox.writer.js';
|
|
3
3
|
export * from './consumers/event-queue.consumer.js';
|
|
4
4
|
export * from './consumers/jobs-outbox.consumer.js';
|
|
5
|
+
export * from './dispatchers/event-queue.dispatcher.js';
|
|
6
|
+
export * from './dispatchers/jobs-outbox.dispatcher.js';
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AAEpD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
|
2
2
|
import { EventQueueConsumer } from '../../../consumers/event-queue.consumer.js';
|
|
3
3
|
import { makeEventQueueConsumerRepositoryMock, } from '../../utils/helpers/event-queue-repository-mock.helper.js';
|
|
4
4
|
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
5
|
+
import { OutboxStatus } from '@volontariapp/database';
|
|
5
6
|
describe('EventQueueConsumer (Unit)', () => {
|
|
6
7
|
let consumer;
|
|
7
8
|
let repository;
|
|
@@ -20,5 +21,27 @@ describe('EventQueueConsumer (Unit)', () => {
|
|
|
20
21
|
expect(repository.executeInTransaction).toHaveBeenCalled();
|
|
21
22
|
expect(result).toEqual(mockEntities);
|
|
22
23
|
});
|
|
24
|
+
describe('processItems', () => {
|
|
25
|
+
it('should process items and mark them as completed', async () => {
|
|
26
|
+
const entities = [{ id: '1' }, { id: '2' }];
|
|
27
|
+
const dispatcherSpy = jest.spyOn(consumer.outboxDispatcher, 'markAsCompleted');
|
|
28
|
+
await consumer.processItems(entities);
|
|
29
|
+
expect(dispatcherSpy).toHaveBeenCalledTimes(2);
|
|
30
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[0]);
|
|
31
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[1]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('markItemsAsCompleted', () => {
|
|
35
|
+
it('should mark processing items as completed', async () => {
|
|
36
|
+
const entities = [
|
|
37
|
+
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
38
|
+
{ id: '2', status: OutboxStatus.PENDING },
|
|
39
|
+
];
|
|
40
|
+
const dispatcherSpy = jest.spyOn(consumer.outboxDispatcher, 'markAsCompleted');
|
|
41
|
+
await consumer.markItemsAsCompleted(entities);
|
|
42
|
+
expect(dispatcherSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[0]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
23
46
|
});
|
|
24
47
|
//# sourceMappingURL=event-queue.consumer.unit.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/event/event-queue.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/event/event-queue.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,E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CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
|
2
2
|
import { JobsOutboxConsumer } from '../../../consumers/jobs-outbox.consumer.js';
|
|
3
3
|
import { makeJobsOutboxConsumerRepositoryMock, } from '../../utils/helpers/jobs-outbox-repository-mock.helper.js';
|
|
4
4
|
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
5
|
+
import { OutboxStatus } from '@volontariapp/database';
|
|
5
6
|
describe('JobsOutboxConsumer (Unit)', () => {
|
|
6
7
|
let consumer;
|
|
7
8
|
let repository;
|
|
@@ -20,5 +21,27 @@ describe('JobsOutboxConsumer (Unit)', () => {
|
|
|
20
21
|
expect(repository.executeInTransaction).toHaveBeenCalled();
|
|
21
22
|
expect(result).toEqual(mockEntities);
|
|
22
23
|
});
|
|
24
|
+
describe('processItems', () => {
|
|
25
|
+
it('should process items and mark them as completed', async () => {
|
|
26
|
+
const entities = [{ id: '1' }, { id: '2' }];
|
|
27
|
+
const dispatcherSpy = jest.spyOn(consumer.outboxDispatcher, 'markAsCompleted');
|
|
28
|
+
await consumer.processItems(entities);
|
|
29
|
+
expect(dispatcherSpy).toHaveBeenCalledTimes(2);
|
|
30
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[0]);
|
|
31
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[1]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('markItemsAsCompleted', () => {
|
|
35
|
+
it('should mark processing items as completed', async () => {
|
|
36
|
+
const entities = [
|
|
37
|
+
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
38
|
+
{ id: '2', status: OutboxStatus.PENDING },
|
|
39
|
+
];
|
|
40
|
+
const dispatcherSpy = jest.spyOn(consumer.outboxDispatcher, 'markAsCompleted');
|
|
41
|
+
await consumer.markItemsAsCompleted(entities);
|
|
42
|
+
expect(dispatcherSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(dispatcherSpy).toHaveBeenCalledWith(entities[0]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
23
46
|
});
|
|
24
47
|
//# sourceMappingURL=jobs-outbox.consumer.unit.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/jobs/jobs-outbox.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/jobs/jobs-outbox.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EACL,oCAAoC,GAErC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAuB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3E,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,QAA4B,CAAC;IACjC,IAAI,UAA4C,CAAC;IACjD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAEhC,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG,oCAAoC,EAAE,CAAC;QACpD,QAAQ,GAAG,IAAI,kBAAkB,CAC/B,MAA2B,EAC3B,UAAuE,EACvE,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,QA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2C,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,QAAQ,GAAG;gBACf,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,UAAU,EAAsB;gBAChE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAsB;aAC9D,CAAC;YACF,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAC7B,QAAkE,CAAC,gBAAgB,EACpF,iBAAiB,CAClB,CAAC;YAEF,MAAM,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAE9C,MAAM,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,aAAa,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.int.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.int.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, expect, it, beforeAll, afterAll, beforeEach } from '@jest/globals';
|
|
2
|
+
import { databaseMapper, EventQueueModel, EventQueueEntity, OutboxStatus, } from '@volontariapp/database';
|
|
3
|
+
import { testDataSource, initializeTestDb, closeTestDb } from '../../data-source.js';
|
|
4
|
+
import { EventQueueDispatcher } from '../../../dispatchers/event-queue.dispatcher.js';
|
|
5
|
+
import { TestEventQueueRepository } from '../../utils/repositories/event-queue-test.repository.js';
|
|
6
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
7
|
+
describe('EventQueueDispatcher (Integration)', () => {
|
|
8
|
+
let dispatcher;
|
|
9
|
+
let repository;
|
|
10
|
+
const logger = makeLoggerMock();
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
await initializeTestDb();
|
|
13
|
+
databaseMapper.registerBidirectional(EventQueueModel, EventQueueEntity);
|
|
14
|
+
repository = new TestEventQueueRepository(testDataSource.getRepository(EventQueueModel));
|
|
15
|
+
dispatcher = new EventQueueDispatcher(logger, repository);
|
|
16
|
+
});
|
|
17
|
+
afterAll(async () => {
|
|
18
|
+
await closeTestDb();
|
|
19
|
+
});
|
|
20
|
+
beforeEach(async () => {
|
|
21
|
+
await testDataSource.getRepository(EventQueueModel).createQueryBuilder().delete().execute();
|
|
22
|
+
});
|
|
23
|
+
it('markAsProcessing() should update status in database', async () => {
|
|
24
|
+
const repo = testDataSource.getRepository(EventQueueModel);
|
|
25
|
+
const event = repo.create({
|
|
26
|
+
id: '00000000-0000-0000-0000-000000000001',
|
|
27
|
+
type: 'test',
|
|
28
|
+
emitter: 'test',
|
|
29
|
+
status: OutboxStatus.PENDING,
|
|
30
|
+
payload: {},
|
|
31
|
+
version: 1,
|
|
32
|
+
updatedAt: new Date(),
|
|
33
|
+
});
|
|
34
|
+
await repo.save(event);
|
|
35
|
+
const entity = await repository.findOneOrFail({ id: event.id });
|
|
36
|
+
await dispatcher.markAsProcessing(entity);
|
|
37
|
+
const updated = await repo.findOneByOrFail({ id: event.id });
|
|
38
|
+
expect(updated.status).toBe(OutboxStatus.PROCESSING);
|
|
39
|
+
});
|
|
40
|
+
it('markAsFailed() should update status and lastError in database', async () => {
|
|
41
|
+
const repo = testDataSource.getRepository(EventQueueModel);
|
|
42
|
+
const event = repo.create({
|
|
43
|
+
id: '00000000-0000-0000-0000-000000000002',
|
|
44
|
+
type: 'test',
|
|
45
|
+
emitter: 'test',
|
|
46
|
+
status: OutboxStatus.PROCESSING,
|
|
47
|
+
payload: {},
|
|
48
|
+
version: 1,
|
|
49
|
+
updatedAt: new Date(),
|
|
50
|
+
});
|
|
51
|
+
await repo.save(event);
|
|
52
|
+
const entity = await repository.findOneOrFail({ id: event.id });
|
|
53
|
+
const error = 'Failure reason';
|
|
54
|
+
await dispatcher.markAsFailed(entity, error);
|
|
55
|
+
const updated = await repo.findOneByOrFail({ id: event.id });
|
|
56
|
+
expect(updated.status).toBe(OutboxStatus.FAILED);
|
|
57
|
+
expect(updated.lastError).toBe(error);
|
|
58
|
+
});
|
|
59
|
+
it('markAsCompleted() should update status to COMPLETED in database', async () => {
|
|
60
|
+
const repo = testDataSource.getRepository(EventQueueModel);
|
|
61
|
+
const event = repo.create({
|
|
62
|
+
id: '00000000-0000-0000-0000-000000000003',
|
|
63
|
+
type: 'test',
|
|
64
|
+
emitter: 'test',
|
|
65
|
+
status: OutboxStatus.PROCESSING,
|
|
66
|
+
payload: {},
|
|
67
|
+
version: 1,
|
|
68
|
+
updatedAt: new Date(),
|
|
69
|
+
});
|
|
70
|
+
await repo.save(event);
|
|
71
|
+
const entity = await repository.findOneOrFail({ id: event.id });
|
|
72
|
+
await dispatcher.markAsCompleted(entity);
|
|
73
|
+
const updated = await repo.findOneByOrFail({ id: event.id });
|
|
74
|
+
expect(updated.status).toBe(OutboxStatus.COMPLETED);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=event-queue.dispatcher.int.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.int.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.int.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAA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C,MAAM,CAAC,CAAC;QACjD,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,IAAI,GAAG,cAAc,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;YACxB,EAAE,EAAE,sCAAsC;YAC1C,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,YAAY,CAAC,UAAU;YAC/B,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,IAAI,IAAI,EAAE;SACM,CAAC,CAAC;QAC/B,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.unit.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.unit.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
2
|
+
import { EventQueueDispatcher } from '../../../dispatchers/event-queue.dispatcher.js';
|
|
3
|
+
import { OutboxStatus } from '@volontariapp/database';
|
|
4
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
5
|
+
import { makeEventQueueRepositoryMock, } from '../../utils/helpers/event-queue-repository-mock.helper.js';
|
|
6
|
+
import { makeEventQueueEvent } from '../../utils/helpers/event-queue-event.helper.js';
|
|
7
|
+
describe('EventQueueDispatcher (Unit)', () => {
|
|
8
|
+
let dispatcher;
|
|
9
|
+
let repositoryMock;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
repositoryMock = makeEventQueueRepositoryMock();
|
|
12
|
+
const loggerMock = makeLoggerMock();
|
|
13
|
+
dispatcher = new EventQueueDispatcher(loggerMock, repositoryMock);
|
|
14
|
+
});
|
|
15
|
+
describe('markAsProcessing', () => {
|
|
16
|
+
it('should mark event as processing and update repository', async () => {
|
|
17
|
+
const event = makeEventQueueEvent({ status: OutboxStatus.PENDING });
|
|
18
|
+
await dispatcher.markAsProcessing(event);
|
|
19
|
+
expect(event.status).toBe(OutboxStatus.PROCESSING);
|
|
20
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(event.id, event);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('markAsFailed', () => {
|
|
24
|
+
it('should mark event as failed with error and update repository', async () => {
|
|
25
|
+
const event = makeEventQueueEvent({ status: OutboxStatus.PROCESSING });
|
|
26
|
+
const error = 'Execution failed';
|
|
27
|
+
await dispatcher.markAsFailed(event, error);
|
|
28
|
+
expect(event.status).toBe(OutboxStatus.FAILED);
|
|
29
|
+
expect(event.lastError).toBe(error);
|
|
30
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(event.id, event);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('markAsCompleted', () => {
|
|
34
|
+
it('should mark event as completed and update repository', async () => {
|
|
35
|
+
const event = makeEventQueueEvent({ status: OutboxStatus.PROCESSING });
|
|
36
|
+
await dispatcher.markAsCompleted(event);
|
|
37
|
+
expect(event.status).toBe(OutboxStatus.COMPLETED);
|
|
38
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(event.id, event);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=event-queue.dispatcher.unit.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,4BAA4B,GAE7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAEtF,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,UAAgC,CAAC;IACrC,IAAI,cAAwC,CAAC;IAE7C,UAAU,CAAC,GAAG,EAAE;QACd,cAAc,GAAG,4BAA4B,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;QACpC,UAAU,GAAG,IAAI,oBAAoB,CACnC,UAAU,EACV,cAAsF,CACvF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,KAAK,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YACpE,MAAM,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YA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,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.int.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, expect, it, beforeAll, afterAll, beforeEach } from '@jest/globals';
|
|
2
|
+
import { databaseMapper, JobsOutboxModel, JobsOutboxEntity, OutboxStatus, } from '@volontariapp/database';
|
|
3
|
+
import { testDataSource, initializeTestDb, closeTestDb } from '../../data-source.js';
|
|
4
|
+
import { JobsOutboxDispatcher } from '../../../dispatchers/jobs-outbox.dispatcher.js';
|
|
5
|
+
import { TestJobsOutboxRepository } from '../../utils/repositories/jobs-outbox-test.repository.js';
|
|
6
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
7
|
+
describe('JobsOutboxDispatcher (Integration)', () => {
|
|
8
|
+
let dispatcher;
|
|
9
|
+
let repository;
|
|
10
|
+
const logger = makeLoggerMock();
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
await initializeTestDb();
|
|
13
|
+
databaseMapper.registerBidirectional(JobsOutboxModel, JobsOutboxEntity);
|
|
14
|
+
repository = new TestJobsOutboxRepository(testDataSource.getRepository(JobsOutboxModel));
|
|
15
|
+
dispatcher = new JobsOutboxDispatcher(logger, repository);
|
|
16
|
+
});
|
|
17
|
+
afterAll(async () => {
|
|
18
|
+
await closeTestDb();
|
|
19
|
+
});
|
|
20
|
+
beforeEach(async () => {
|
|
21
|
+
await testDataSource.getRepository(JobsOutboxModel).createQueryBuilder().delete().execute();
|
|
22
|
+
});
|
|
23
|
+
it('markAsProcessing() should update status in database', async () => {
|
|
24
|
+
const repo = testDataSource.getRepository(JobsOutboxModel);
|
|
25
|
+
const job = repo.create({
|
|
26
|
+
id: '00000000-0000-0000-0000-000000000001',
|
|
27
|
+
type: 'test',
|
|
28
|
+
emitter: 'test',
|
|
29
|
+
status: OutboxStatus.PENDING,
|
|
30
|
+
payload: {},
|
|
31
|
+
target: 'test',
|
|
32
|
+
updatedAt: new Date(),
|
|
33
|
+
scheduledAt: new Date(),
|
|
34
|
+
});
|
|
35
|
+
await repo.save(job);
|
|
36
|
+
const entity = await repository.findOneOrFail({ id: job.id });
|
|
37
|
+
await dispatcher.markAsProcessing(entity);
|
|
38
|
+
const updated = await repo.findOneByOrFail({ id: job.id });
|
|
39
|
+
expect(updated.status).toBe(OutboxStatus.PROCESSING);
|
|
40
|
+
});
|
|
41
|
+
it('markAsFailed() should update status and lastError in database', async () => {
|
|
42
|
+
const repo = testDataSource.getRepository(JobsOutboxModel);
|
|
43
|
+
const job = repo.create({
|
|
44
|
+
id: '00000000-0000-0000-0000-000000000002',
|
|
45
|
+
type: 'test',
|
|
46
|
+
emitter: 'test',
|
|
47
|
+
status: OutboxStatus.PROCESSING,
|
|
48
|
+
payload: {},
|
|
49
|
+
target: 'test',
|
|
50
|
+
updatedAt: new Date(),
|
|
51
|
+
scheduledAt: new Date(),
|
|
52
|
+
});
|
|
53
|
+
await repo.save(job);
|
|
54
|
+
const entity = await repository.findOneOrFail({ id: job.id });
|
|
55
|
+
const error = 'Job failure';
|
|
56
|
+
await dispatcher.markAsFailed(entity, error);
|
|
57
|
+
const updated = await repo.findOneByOrFail({ id: job.id });
|
|
58
|
+
expect(updated.status).toBe(OutboxStatus.FAILED);
|
|
59
|
+
expect(updated.lastError).toBe(error);
|
|
60
|
+
});
|
|
61
|
+
it('markAsCompleted() should update status to COMPLETED in database', async () => {
|
|
62
|
+
const repo = testDataSource.getRepository(JobsOutboxModel);
|
|
63
|
+
const job = repo.create({
|
|
64
|
+
id: '00000000-0000-0000-0000-000000000003',
|
|
65
|
+
type: 'test',
|
|
66
|
+
emitter: 'test',
|
|
67
|
+
status: OutboxStatus.PROCESSING,
|
|
68
|
+
payload: {},
|
|
69
|
+
target: 'test',
|
|
70
|
+
updatedAt: new Date(),
|
|
71
|
+
scheduledAt: new Date(),
|
|
72
|
+
});
|
|
73
|
+
await repo.save(job);
|
|
74
|
+
const entity = await repository.findOneOrFail({ id: job.id });
|
|
75
|
+
await dispatcher.markAsCompleted(entity);
|
|
76
|
+
const updated = await repo.findOneByOrFail({ id: job.id });
|
|
77
|
+
expect(updated.status).toBe(OutboxStatus.COMPLETED);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=jobs-outbox.dispatcher.int.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.int.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.int.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,IAAI,UAAgC,CAAC;IACrC,IAAI,UAAoC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAEhC,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,gBAAgB,EAAE,CAAC;QACzB,cAAc,C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,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;YACtB,EAAE,EAAE,sCAAsC;YAC1C,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,YAAY,CAAC,UAAU;YAC/B,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,WAAW,EAAE,IAAI,IAAI,EAAE;SACI,CAAC,CAAC;QAC/B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAErB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9D,MAAM,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.unit.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
2
|
+
import { JobsOutboxDispatcher } from '../../../dispatchers/jobs-outbox.dispatcher.js';
|
|
3
|
+
import { OutboxStatus } from '@volontariapp/database';
|
|
4
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
5
|
+
import { makeJobsOutboxRepositoryMock, } from '../../utils/helpers/jobs-outbox-repository-mock.helper.js';
|
|
6
|
+
import { makeJobsOutboxEvent } from '../../utils/helpers/jobs-outbox-event.helper.js';
|
|
7
|
+
describe('JobsOutboxDispatcher (Unit)', () => {
|
|
8
|
+
let dispatcher;
|
|
9
|
+
let repositoryMock;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
repositoryMock = makeJobsOutboxRepositoryMock();
|
|
12
|
+
const loggerMock = makeLoggerMock();
|
|
13
|
+
dispatcher = new JobsOutboxDispatcher(loggerMock, repositoryMock);
|
|
14
|
+
});
|
|
15
|
+
describe('markAsProcessing', () => {
|
|
16
|
+
it('should mark job as processing and update repository', async () => {
|
|
17
|
+
const job = makeJobsOutboxEvent({ status: OutboxStatus.PENDING });
|
|
18
|
+
await dispatcher.markAsProcessing(job);
|
|
19
|
+
expect(job.status).toBe(OutboxStatus.PROCESSING);
|
|
20
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(job.id, job);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('markAsFailed', () => {
|
|
24
|
+
it('should mark job as failed with error and update repository', async () => {
|
|
25
|
+
const job = makeJobsOutboxEvent({ status: OutboxStatus.PROCESSING });
|
|
26
|
+
const error = 'Job execution failed';
|
|
27
|
+
await dispatcher.markAsFailed(job, error);
|
|
28
|
+
expect(job.status).toBe(OutboxStatus.FAILED);
|
|
29
|
+
expect(job.lastError).toBe(error);
|
|
30
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(job.id, job);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('markAsCompleted', () => {
|
|
34
|
+
it('should mark job as completed and update repository', async () => {
|
|
35
|
+
const job = makeJobsOutboxEvent({ status: OutboxStatus.PROCESSING });
|
|
36
|
+
await dispatcher.markAsCompleted(job);
|
|
37
|
+
expect(job.status).toBe(OutboxStatus.COMPLETED);
|
|
38
|
+
expect(repositoryMock.update).toHaveBeenCalledWith(job.id, job);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=jobs-outbox.dispatcher.unit.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,4BAA4B,GAE7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAEtF,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,UAAgC,CAAC;IACrC,IAAI,cAAwC,CAAC;IAE7C,UAAU,CAAC,GAAG,EAAE;QACd,cAAc,GAAG,4BAA4B,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;QACpC,UAAU,GAAG,IAAI,oBAAoB,CACnC,UAAU,EACV,cAAsF,CACvF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;YACnE,MAAM,GAAG,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,MAAM,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAEvC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YACjD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,GA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,8 @@
|
|
|
1
1
|
import type { EventQueueEntity } from '@volontariapp/database';
|
|
2
2
|
import { EventQueueModel } from '@volontariapp/database';
|
|
3
|
-
import { type
|
|
3
|
+
import { type OutboxRepositoryMock } from './outbox-repository-mock.helper.js';
|
|
4
4
|
import { type OutboxConsumerRepositoryMock } from './outbox-consumer-repository-mock.helper.js';
|
|
5
|
-
export type EventQueueRepositoryMock =
|
|
5
|
+
export type EventQueueRepositoryMock = OutboxRepositoryMock<EventQueueEntity>;
|
|
6
6
|
export declare function makeEventQueueRepositoryMock(): EventQueueRepositoryMock;
|
|
7
7
|
export type EventQueueConsumerRepositoryMock = OutboxConsumerRepositoryMock<EventQueueModel, EventQueueEntity>;
|
|
8
8
|
export declare function makeEventQueueConsumerRepositoryMock(): EventQueueConsumerRepositoryMock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"event-queue-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AAE9E,wBAAgB,4BAA4B,IAAI,wBAAwB,CAEvE;AAED,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CACzE,eAAe,EACf,gBAAgB,CACjB,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,gCAAgC,CAEvF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EventQueueModel } from '@volontariapp/database';
|
|
2
|
-
import {
|
|
2
|
+
import { makeOutboxRepositoryMock, } from './outbox-repository-mock.helper.js';
|
|
3
3
|
import { makeOutboxConsumerRepositoryMock, } from './outbox-consumer-repository-mock.helper.js';
|
|
4
4
|
export function makeEventQueueRepositoryMock() {
|
|
5
|
-
return
|
|
5
|
+
return makeOutboxRepositoryMock();
|
|
6
6
|
}
|
|
7
7
|
export function makeEventQueueConsumerRepositoryMock() {
|
|
8
8
|
return makeOutboxConsumerRepositoryMock(EventQueueModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"event-queue-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,EAAoB,CAAC;AACtD,CAAC;AAOD,MAAM,UAAU,oCAAoC;IAClD,OAAO,gCAAgC,CAAoC,eAAe,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JobsOutboxEntity } from '@volontariapp/database';
|
|
2
2
|
import { JobsOutboxModel } from '@volontariapp/database';
|
|
3
|
-
import { type
|
|
3
|
+
import { type OutboxRepositoryMock } from './outbox-repository-mock.helper.js';
|
|
4
4
|
import { type OutboxConsumerRepositoryMock } from './outbox-consumer-repository-mock.helper.js';
|
|
5
|
-
export type JobsOutboxRepositoryMock =
|
|
5
|
+
export type JobsOutboxRepositoryMock = OutboxRepositoryMock<JobsOutboxEntity>;
|
|
6
6
|
export declare function makeJobsOutboxRepositoryMock(): JobsOutboxRepositoryMock;
|
|
7
7
|
export type JobsOutboxConsumerRepositoryMock = OutboxConsumerRepositoryMock<JobsOutboxModel, JobsOutboxEntity>;
|
|
8
8
|
export declare function makeJobsOutboxConsumerRepositoryMock(): JobsOutboxConsumerRepositoryMock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"jobs-outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AAE9E,wBAAgB,4BAA4B,IAAI,wBAAwB,CAEvE;AAED,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CACzE,eAAe,EACf,gBAAgB,CACjB,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,gCAAgC,CAEvF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JobsOutboxModel } from '@volontariapp/database';
|
|
2
|
-
import {
|
|
2
|
+
import { makeOutboxRepositoryMock, } from './outbox-repository-mock.helper.js';
|
|
3
3
|
import { makeOutboxConsumerRepositoryMock, } from './outbox-consumer-repository-mock.helper.js';
|
|
4
4
|
export function makeJobsOutboxRepositoryMock() {
|
|
5
|
-
return
|
|
5
|
+
return makeOutboxRepositoryMock();
|
|
6
6
|
}
|
|
7
7
|
export function makeJobsOutboxConsumerRepositoryMock() {
|
|
8
8
|
return makeOutboxConsumerRepositoryMock(JobsOutboxModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"jobs-outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,EAAoB,CAAC;AACtD,CAAC;AAOD,MAAM,UAAU,oCAAoC;IAClD,OAAO,gCAAgC,CAAoC,eAAe,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import type { OutboxEntity } from '@volontariapp/database';
|
|
3
|
+
export type OutboxRepositoryMock<TEntity extends OutboxEntity> = {
|
|
4
|
+
create: jest.MockedFunction<(data: Partial<TEntity>) => Promise<TEntity>>;
|
|
5
|
+
createMany: jest.MockedFunction<(dataArray: Partial<TEntity>[]) => Promise<TEntity[]>>;
|
|
6
|
+
update: jest.MockedFunction<(id: string, data: Partial<TEntity>) => Promise<TEntity | null>>;
|
|
7
|
+
delete: jest.MockedFunction<(id: string) => Promise<boolean>>;
|
|
8
|
+
};
|
|
9
|
+
export declare const makeOutboxRepositoryMock: <TEntity extends OutboxEntity>() => OutboxRepositoryMock<TEntity>;
|
|
10
|
+
//# sourceMappingURL=outbox-repository-mock.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,YAAY,IAAI;IAC/D,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1E,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACvF,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7F,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,OAAO,SAAS,YAAY,OACzB,oBAAoB,CAAC,OAAO,CAOhC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
export const makeOutboxRepositoryMock = () => {
|
|
3
|
+
return {
|
|
4
|
+
create: jest.fn(() => Promise.resolve({})),
|
|
5
|
+
createMany: jest.fn(() => Promise.resolve([])),
|
|
6
|
+
update: jest.fn(() => Promise.resolve({})),
|
|
7
|
+
delete: jest.fn(() => Promise.resolve(true)),
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=outbox-repository-mock.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAUrC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAEL,EAAE;IACnC,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAa,CAAC,CAAC;QACrD,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAe,CAAC,CAAC;QAC3D,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAa,CAAC,CAAC;QACrD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC7C,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
import { OutboxEntity, OutboxModel } from '@volontariapp/database';
|
|
3
|
-
export type OutboxWriterRepositoryMock<_TModel extends OutboxModel, TEntity extends OutboxEntity> = {
|
|
4
|
-
create: jest.MockedFunction<(data: Partial<TEntity>) => Promise<TEntity>>;
|
|
5
|
-
createMany: jest.MockedFunction<(dataArray: Partial<TEntity>[]) => Promise<TEntity[]>>;
|
|
6
|
-
update: jest.MockedFunction<(id: string, data: Partial<TEntity>) => Promise<TEntity | null>>;
|
|
7
|
-
delete: jest.MockedFunction<(id: string) => Promise<boolean>>;
|
|
8
|
-
};
|
|
9
|
-
export declare const makeOutboxWriterRepositoryMock: <_TModel extends OutboxModel, TEntity extends OutboxEntity>() => OutboxWriterRepositoryMock<_TModel, TEntity>;
|
|
10
|
-
//# sourceMappingURL=outbox-writer-mock.helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-writer-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-writer-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,WAAW,EAC3B,OAAO,SAAS,YAAY,IAC1B;IACF,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1E,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACvF,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7F,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACzC,OAAO,SAAS,WAAW,EAC3B,OAAO,SAAS,YAAY,OACzB,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAO/C,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
export const makeOutboxWriterRepositoryMock = () => {
|
|
3
|
-
return {
|
|
4
|
-
create: jest.fn(async () => ({})),
|
|
5
|
-
createMany: jest.fn(async () => []),
|
|
6
|
-
update: jest.fn(async () => ({})),
|
|
7
|
-
delete: jest.fn(async () => true),
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=outbox-writer-mock.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-writer-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-writer-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAarC,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAGI,EAAE;IAClD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAY,CAAC;QAC5C,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,EAAe,CAAC;QAChD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAY,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC,CAAC"}
|