@zdavison/matador 4.0.3 → 4.2.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/core/matador.d.ts.map +1 -1
- package/dist/core/matador.js +4 -1
- package/dist/index.cjs +156 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/pipeline.d.ts +30 -2
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/pipeline.js +65 -9
- package/dist/retry/index.d.ts +1 -1
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/policy.d.ts +27 -0
- package/dist/retry/policy.d.ts.map +1 -1
- package/dist/retry/standard-policy.d.ts +33 -2
- package/dist/retry/standard-policy.d.ts.map +1 -1
- package/dist/retry/standard-policy.js +73 -9
- package/dist/topology/types.d.ts +14 -0
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.d.ts.map +1 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.js +3 -0
- package/package.json +1 -1
- package/dist/checkpoint/context.test.d.ts +0 -2
- package/dist/checkpoint/context.test.d.ts.map +0 -1
- package/dist/checkpoint/context.test.js +0 -428
- package/dist/checkpoint/stores/stores.test.d.ts +0 -2
- package/dist/checkpoint/stores/stores.test.d.ts.map +0 -1
- package/dist/checkpoint/stores/stores.test.js +0 -146
- package/dist/codec/rabbitmq-codec.test.d.ts +0 -2
- package/dist/codec/rabbitmq-codec.test.d.ts.map +0 -1
- package/dist/codec/rabbitmq-codec.test.js +0 -428
- package/dist/core/fanout.test.d.ts +0 -2
- package/dist/core/fanout.test.d.ts.map +0 -1
- package/dist/core/fanout.test.js +0 -1970
- package/dist/core/matador.test.d.ts +0 -2
- package/dist/core/matador.test.d.ts.map +0 -1
- package/dist/core/matador.test.js +0 -813
- package/dist/core/shutdown.test.d.ts +0 -2
- package/dist/core/shutdown.test.d.ts.map +0 -1
- package/dist/core/shutdown.test.js +0 -599
- package/dist/errors/retry-errors.test.d.ts +0 -2
- package/dist/errors/retry-errors.test.d.ts.map +0 -1
- package/dist/errors/retry-errors.test.js +0 -136
- package/dist/pipeline/pipeline.test.d.ts +0 -2
- package/dist/pipeline/pipeline.test.d.ts.map +0 -1
- package/dist/pipeline/pipeline.test.js +0 -1124
- package/dist/retry/standard-policy.test.d.ts +0 -2
- package/dist/retry/standard-policy.test.d.ts.map +0 -1
- package/dist/retry/standard-policy.test.js +0 -196
- package/dist/schema/registry.test.d.ts +0 -2
- package/dist/schema/registry.test.d.ts.map +0 -1
- package/dist/schema/registry.test.js +0 -278
- package/dist/schema/types.test.d.ts +0 -2
- package/dist/schema/types.test.d.ts.map +0 -1
- package/dist/schema/types.test.js +0 -246
- package/dist/topology/builder.test.d.ts +0 -2
- package/dist/topology/builder.test.d.ts.map +0 -1
- package/dist/topology/builder.test.js +0 -547
- package/dist/transport/local/local-transport.test.d.ts +0 -2
- package/dist/transport/local/local-transport.test.d.ts.map +0 -1
- package/dist/transport/local/local-transport.test.js +0 -232
- package/dist/transport/multi/multi-transport.test.d.ts +0 -2
- package/dist/transport/multi/multi-transport.test.d.ts.map +0 -1
- package/dist/transport/multi/multi-transport.test.js +0 -322
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts +0 -2
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts.map +0 -1
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.js +0 -149
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts +0 -2
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts.map +0 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.test.js +0 -230
- package/dist/types/event.test.d.ts +0 -2
- package/dist/types/event.test.d.ts.map +0 -1
- package/dist/types/event.test.js +0 -130
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { createEnvelope } from '../types/envelope.js';
|
|
3
|
-
import { DoRetry, DontRetry, EventAssertionError, assertEvent, isAssertionError, isDoRetry, isDontRetry, } from './retry-errors.js';
|
|
4
|
-
function createTestEnvelope(data = { foo: 'bar' }) {
|
|
5
|
-
return createEnvelope({
|
|
6
|
-
data,
|
|
7
|
-
eventKey: 'test.event',
|
|
8
|
-
targetSubscriber: 'test-subscriber',
|
|
9
|
-
importance: 'can-ignore',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe('retry-errors', () => {
|
|
13
|
-
describe('DoRetry', () => {
|
|
14
|
-
it('should have correct name', () => {
|
|
15
|
-
const error = new DoRetry('test message');
|
|
16
|
-
expect(error.name).toBe('DoRetry');
|
|
17
|
-
});
|
|
18
|
-
it('should have description', () => {
|
|
19
|
-
const error = new DoRetry('test message');
|
|
20
|
-
expect(error.description).toBeDefined();
|
|
21
|
-
});
|
|
22
|
-
it('should serialize to JSON', () => {
|
|
23
|
-
const error = new DoRetry('test message');
|
|
24
|
-
const json = error.toJSON();
|
|
25
|
-
expect(json.name).toBe('DoRetry');
|
|
26
|
-
expect(json.message).toBe('test message');
|
|
27
|
-
expect(json.description).toBeDefined();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('DontRetry', () => {
|
|
31
|
-
it('should have correct name', () => {
|
|
32
|
-
const error = new DontRetry('test message');
|
|
33
|
-
expect(error.name).toBe('DontRetry');
|
|
34
|
-
});
|
|
35
|
-
it('should have description', () => {
|
|
36
|
-
const error = new DontRetry('test message');
|
|
37
|
-
expect(error.description).toBeDefined();
|
|
38
|
-
});
|
|
39
|
-
it('should serialize to JSON', () => {
|
|
40
|
-
const error = new DontRetry('test message');
|
|
41
|
-
const json = error.toJSON();
|
|
42
|
-
expect(json.name).toBe('DontRetry');
|
|
43
|
-
expect(json.message).toBe('test message');
|
|
44
|
-
expect(json.description).toBeDefined();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('EventAssertionError', () => {
|
|
48
|
-
it('should have correct name', () => {
|
|
49
|
-
const envelope = createTestEnvelope();
|
|
50
|
-
const error = new EventAssertionError(envelope, 'assertion failed');
|
|
51
|
-
expect(error.name).toBe('EventAssertionError');
|
|
52
|
-
});
|
|
53
|
-
it('should store the envelope', () => {
|
|
54
|
-
const envelope = createTestEnvelope();
|
|
55
|
-
const error = new EventAssertionError(envelope, 'assertion failed');
|
|
56
|
-
expect(error.envelope).toBe(envelope);
|
|
57
|
-
});
|
|
58
|
-
it('should have description', () => {
|
|
59
|
-
const envelope = createTestEnvelope();
|
|
60
|
-
const error = new EventAssertionError(envelope, 'assertion failed');
|
|
61
|
-
expect(error.description).toBeDefined();
|
|
62
|
-
expect(error.description).toContain('NOT to retry');
|
|
63
|
-
});
|
|
64
|
-
it('should serialize to JSON with envelope', () => {
|
|
65
|
-
const envelope = createTestEnvelope();
|
|
66
|
-
const error = new EventAssertionError(envelope, 'assertion failed');
|
|
67
|
-
const json = error.toJSON();
|
|
68
|
-
expect(json.name).toBe('EventAssertionError');
|
|
69
|
-
expect(json.message).toBe('assertion failed');
|
|
70
|
-
expect(json.envelope).toBe(envelope);
|
|
71
|
-
expect(json.description).toBeDefined();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('assertEvent', () => {
|
|
75
|
-
it('should not throw when value is truthy', () => {
|
|
76
|
-
const envelope = createTestEnvelope();
|
|
77
|
-
expect(() => assertEvent(envelope, true, 'should be true')).not.toThrow();
|
|
78
|
-
expect(() => assertEvent(envelope, 'string', 'should be string')).not.toThrow();
|
|
79
|
-
expect(() => assertEvent(envelope, 1, 'should be number')).not.toThrow();
|
|
80
|
-
expect(() => assertEvent(envelope, {}, 'should be object')).not.toThrow();
|
|
81
|
-
expect(() => assertEvent(envelope, [], 'should be array')).not.toThrow();
|
|
82
|
-
});
|
|
83
|
-
it('should throw EventAssertionError when value is falsy', () => {
|
|
84
|
-
const envelope = createTestEnvelope();
|
|
85
|
-
expect(() => assertEvent(envelope, false, 'value was false')).toThrow(EventAssertionError);
|
|
86
|
-
expect(() => assertEvent(envelope, null, 'value was null')).toThrow(EventAssertionError);
|
|
87
|
-
expect(() => assertEvent(envelope, undefined, 'value was undefined')).toThrow(EventAssertionError);
|
|
88
|
-
expect(() => assertEvent(envelope, 0, 'value was zero')).toThrow(EventAssertionError);
|
|
89
|
-
expect(() => assertEvent(envelope, '', 'value was empty string')).toThrow(EventAssertionError);
|
|
90
|
-
});
|
|
91
|
-
it('should include envelope in thrown error', () => {
|
|
92
|
-
const envelope = createTestEnvelope();
|
|
93
|
-
try {
|
|
94
|
-
assertEvent(envelope, false, 'assertion failed');
|
|
95
|
-
expect.unreachable('should have thrown');
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
expect(error).toBeInstanceOf(EventAssertionError);
|
|
99
|
-
expect(error.envelope).toBe(envelope);
|
|
100
|
-
expect(error.message).toBe('assertion failed');
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
it('should include message in thrown error', () => {
|
|
104
|
-
const envelope = createTestEnvelope();
|
|
105
|
-
try {
|
|
106
|
-
assertEvent(envelope, null, 'userId is required');
|
|
107
|
-
expect.unreachable('should have thrown');
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
expect(error).toBeInstanceOf(EventAssertionError);
|
|
111
|
-
expect(error.message).toBe('userId is required');
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('type guards', () => {
|
|
116
|
-
it('isDoRetry should identify DoRetry errors', () => {
|
|
117
|
-
expect(isDoRetry(new DoRetry('test'))).toBe(true);
|
|
118
|
-
expect(isDoRetry(new DontRetry('test'))).toBe(false);
|
|
119
|
-
expect(isDoRetry(new Error('test'))).toBe(false);
|
|
120
|
-
expect(isDoRetry(null)).toBe(false);
|
|
121
|
-
});
|
|
122
|
-
it('isDontRetry should identify DontRetry errors', () => {
|
|
123
|
-
expect(isDontRetry(new DontRetry('test'))).toBe(true);
|
|
124
|
-
expect(isDontRetry(new DoRetry('test'))).toBe(false);
|
|
125
|
-
expect(isDontRetry(new Error('test'))).toBe(false);
|
|
126
|
-
expect(isDontRetry(null)).toBe(false);
|
|
127
|
-
});
|
|
128
|
-
it('isAssertionError should identify EventAssertionError', () => {
|
|
129
|
-
const envelope = createTestEnvelope();
|
|
130
|
-
expect(isAssertionError(new EventAssertionError(envelope, 'test'))).toBe(true);
|
|
131
|
-
expect(isAssertionError(new DoRetry('test'))).toBe(false);
|
|
132
|
-
expect(isAssertionError(new Error('test'))).toBe(false);
|
|
133
|
-
expect(isAssertionError(null)).toBe(false);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.test.d.ts","sourceRoot":"","sources":["../../src/pipeline/pipeline.test.ts"],"names":[],"mappings":""}
|