Skip to content

Commit 7cc67bb

Browse files
committed
improve coverage
1 parent 8ad909a commit 7cc67bb

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

infrastructure/terraform/components/api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ No requirements.
1212
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS Account ID (numeric) | `string` | n/a | yes |
1313
| <a name="input_ca_pem_filename"></a> [ca\_pem\_filename](#input\_ca\_pem\_filename) | Filename for the CA truststore file within the s3 bucket | `string` | `null` | no |
1414
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"supapi"` | no |
15+
| <a name="input_core_account_id"></a> [core\_account\_id](#input\_core\_account\_id) | AWS Account ID for Core | `string` | `"000000000000"` | no |
16+
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
1517
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1618
| <a name="input_enable_backups"></a> [enable\_backups](#input\_enable\_backups) | Enable backups | `bool` | `false` | no |
1719
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |

lambdas/letter-updates-transformer/src/__tests__/letter-updates-transformer.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,53 @@ describe("letter-updates-transformer Lambda", () => {
182182

183183
expect(mockedDeps.snsClient.send).not.toHaveBeenCalled();
184184
});
185+
186+
it("throws error when kinesis data contains malformed JSON", async () => {
187+
const handler = createHandler(mockedDeps);
188+
189+
// Create a Kinesis event with malformed JSON data
190+
const malformedKinesisEvent: KinesisStreamEvent = {
191+
Records: [{
192+
kinesis: {
193+
data: Buffer.from("invalid-json-data").toString("base64"),
194+
sequenceNumber: "12345"
195+
}
196+
} as any]
197+
};
198+
199+
await expect(
200+
handler(malformedKinesisEvent, mockDeep<Context>(), jest.fn())
201+
).rejects.toThrow();
202+
203+
expect(mockedDeps.logger.error).toHaveBeenCalledWith(
204+
expect.objectContaining({
205+
description: "Error extracting payload",
206+
error: expect.any(Error),
207+
record: expect.objectContaining({
208+
kinesis: expect.objectContaining({
209+
data: Buffer.from("invalid-json-data").toString("base64")
210+
})
211+
})
212+
})
213+
);
214+
});
215+
216+
it("handles events with no records", async () => {
217+
const handler = createHandler(mockedDeps);
218+
219+
// Create a Kinesis event with empty Records array
220+
const emptyKinesisEvent: KinesisStreamEvent = { Records: [] };
221+
222+
await handler(emptyKinesisEvent, mockDeep<Context>(), jest.fn());
223+
224+
expect(mockedDeps.logger.info).toHaveBeenCalledWith(
225+
expect.objectContaining({
226+
description: "Number of records",
227+
count: 0
228+
})
229+
);
230+
expect(mockedDeps.snsClient.send).not.toHaveBeenCalled();
231+
});
185232
});
186233

187234
describe("Batching", () => {

0 commit comments

Comments
 (0)