Skip to content

Commit

Permalink
feat: add selective destroyer
Browse files Browse the repository at this point in the history
  • Loading branch information
fgiova committed Nov 17, 2023
1 parent e0d0bc2 commit 96f2647
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ MiniSQSClient.deleteMessage(queueARN: string, receiptHandle: string): Promise<bo
MiniSQSClient.deleteMessageBatch(queueARN: string, receiptHandles: string[]): Promise<boolean>
MiniSQSClient.changeMessageVisibility(queueARN: string, receiptHandle: string, visibilityTimeout: number): Promise<boolean>
MiniSQSClient.changeMessageVisibilityBatch(queueARN: string, receiptHandles: string[], visibilityTimeout: number): Promise<boolean>
MiniSQSClient.destroy(signer: boolean): Promise<boolean> // signer destroyer default true
```

All types are defined in [schemas.ts](./src/schemas.ts) and are derived from the [AWS SQS API](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_Operations.html) <br />
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export class MiniSQSClient {
}
}

async destroy () {
async destroy (signer = true) {
return Promise.all([
this.pool.destroy(),
this.signer.destroy()
signer && this.signer.destroy() || true
]);
}

Expand Down
5 changes: 4 additions & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ test("MiniSQSClient", { only: true }, async (t) => {

await t.test("sendMessage Using signer instance", async (t) => {
const { mockPool } = t.context;
const signer = new Signer();
const client = new MiniSQSClient("eu-central-1", undefined, {
factory: () => mockPool
}, new Signer());
}, signer);
const message: SendMessage = {
MessageBody: "Hello World!"
};
Expand All @@ -75,6 +76,8 @@ test("MiniSQSClient", { only: true }, async (t) => {
}).reply(200, mockResponse);
const result = await client.sendMessage(queueARN,message);
t.same(result, mockResponse);
await t.resolves(client.destroy(false));
await t.resolves(signer.destroy());
});
await t.test("sendMessage Using signer options", async (t) => {
const { mockPool } = t.context;
Expand Down

0 comments on commit 96f2647

Please sign in to comment.