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
2 changes: 0 additions & 2 deletions packages/idempotency/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class IdempotencyInconsistentStateError extends IdempotencyUnknownError {
* Unrecoverable error from the data store
*/
class IdempotencyPersistenceLayerError extends IdempotencyUnknownError {
public readonly cause: Error | undefined;

public constructor(message: string, options?: ErrorOptions) {
super(message, options);
this.name = 'IdempotencyPersistenceLayerError';
Expand Down
27 changes: 13 additions & 14 deletions packages/idempotency/tests/unit/IdempotencyHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* Test Idempotency Handler
*
* @group unit/idempotency/IdempotencyHandler
*/
import { IdempotencyRecord } from '../../src/persistence/index.js';
import { IdempotencyHandler } from '../../src/IdempotencyHandler.js';
import { IdempotencyRecordStatus, MAX_RETRIES } from '../../src/constants.js';
import {
IdempotencyConfig,
IdempotencyAlreadyInProgressError,
IdempotencyConfig,
IdempotencyInconsistentStateError,
IdempotencyItemAlreadyExistsError,
IdempotencyPersistenceLayerError,
} from '../../src/index.js';
import { MAX_RETRIES, IdempotencyRecordStatus } from '../../src/constants.js';
/**
* Test Idempotency Handler
*
* @group unit/idempotency/IdempotencyHandler
*/
import { IdempotencyRecord } from '../../src/persistence/index.js';
import { PersistenceLayerTestClass } from '../helpers/idempotencyUtils.js';

const mockFunctionToMakeIdempotent = jest.fn();
Expand Down Expand Up @@ -198,12 +198,11 @@ describe('Class IdempotencyHandler', () => {
.mockRejectedValue(new Error('Some error'));

// Act & Assess
await expect(idempotentHandler.getFunctionResult()).rejects.toThrow(
new IdempotencyPersistenceLayerError(
'Failed to delete record from idempotency store',
new Error('Some error')
)
);
await expect(idempotentHandler.getFunctionResult()).rejects.toThrow({
name: 'IdempotencyPersistenceLayerError',
message: 'Failed to delete record from idempotency store',
cause: new Error('Some error'),
});
expect(mockDeleteInProgress).toHaveBeenCalledTimes(1);
});

Expand Down
3 changes: 3 additions & 0 deletions packages/idempotency/tests/unit/makeIdempotent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ describe('Function: makeIdempotent', () => {
await expect(handler(event, context)).rejects.toThrow({
name: 'IdempotencyPersistenceLayerError',
message: 'Failed to save in progress record to idempotency store',
cause: new Error('Something went wrong'),
});
}
);
Expand All @@ -166,6 +167,7 @@ describe('Function: makeIdempotent', () => {
await expect(handler(event, context)).rejects.toThrow({
name: 'IdempotencyPersistenceLayerError',
message: 'Failed to update success record to idempotency store',
cause: new Error('Something went wrong'),
});
}
);
Expand All @@ -186,6 +188,7 @@ describe('Function: makeIdempotent', () => {
await expect(handler(event, context)).rejects.toThrow({
name: 'IdempotencyPersistenceLayerError',
message: 'Failed to delete record from idempotency store',
cause: new Error('Something went wrong'),
});
}
);
Expand Down