Skip to content

Commit be40ad8

Browse files
committed
Fix test failures
1 parent e3fc82c commit be40ad8

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

internal/datastore/src/__test__/db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function setupDynamoDBContainer() {
2222
accessKeyId: "fakeMyKeyId",
2323
secretAccessKey: "fakeSecretAccessKey",
2424
},
25+
maxAttempts: 1,
2526
});
2627

2728
const docClient = DynamoDBDocumentClient.from(ddbClient);

internal/datastore/src/__test__/letter-queue-repository.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,34 @@ describe("LetterQueueRepository", () => {
238238
expect(await letterExists(db, "supplier1", "letter1")).toBe(false);
239239
});
240240

241+
it("left-pads the priority with zeros in the sort key", async () => {
242+
const pendingLetter = await letterQueueRepository.putLetter(
243+
createLetter({ priority: 5 }),
244+
);
245+
246+
await letterQueueRepository.updateLetterTimestamp(
247+
pendingLetter,
248+
new Date("2026-03-04T13:15:45.000Z"),
249+
);
250+
251+
const letter = await getLetter(db, "supplier1", "letter1");
252+
expect(letter?.queueSortOrderSk).toBe("05-2026-03-04T13:15:45.000Z");
253+
});
254+
255+
it("defaults a missing priority to 10 in the sort key", async () => {
256+
const pendingLetter = await letterQueueRepository.putLetter(
257+
createLetter({ priority: undefined }),
258+
);
259+
260+
await letterQueueRepository.updateLetterTimestamp(
261+
pendingLetter,
262+
new Date("2026-03-04T13:15:45.000Z"),
263+
);
264+
265+
const letter = await getLetter(db, "supplier1", "letter1");
266+
expect(letter?.queueSortOrderSk).toBe("10-2026-03-04T13:15:45.000Z");
267+
});
268+
241269
it("rethrows errors from DynamoDB when updating the letter", async () => {
242270
const misconfiguredRepository = new LetterQueueRepository(
243271
db.docClient,

internal/datastore/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const PendingLetterSchema = z.object({
9292
queueSortOrderSk: z.string().describe("Secondary index SK"),
9393
specificationId: z.string(),
9494
groupId: z.string(),
95+
priority: z.int().min(0).max(99).optional(),
9596
ttl: z.int(),
9697
});
9798

0 commit comments

Comments
 (0)