mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
test(medications): make the repair's idempotency assertion able to fail
The comparison now includes `updated_at`, so a second application that rewrites an already-correct row is visible even when the value it writes is identical. Without it the assertion passed whether or not the guard that skips untouched rows was there.
This commit is contained in:
1 parent
f226a907cb
commit
7b59388887
1 file changed
+7
-1
@@ -74,6 +74,9 @@ async function readItem(prisma: PrismaClient, id: string) {
|
||||
printedExpiry: true,
|
||||
firstUseAt: true,
|
||||
unitsRemaining: true,
|
||||
// Part of the read so the idempotency assertion below can see a
|
||||
// second application touching a row it should have skipped.
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
return row;
|
||||
@@ -280,7 +283,10 @@ describe("0276 inventory expiry container-type repair — integration", () => {
|
||||
expect(row.expiresAt).toEqual(expiresAt);
|
||||
});
|
||||
|
||||
it("is idempotent — a second application changes nothing", async () => {
|
||||
it("is idempotent — a second application touches nothing", async () => {
|
||||
// `updatedAt` is part of the compared shape, so a second pass that
|
||||
// rewrites an already-correct row is visible even when the value it
|
||||
// writes is the same one.
|
||||
const prisma = getPrismaClient();
|
||||
const id = await seedItem(prisma, medicationId, {
|
||||
containerType: "BLISTER",
|
||||
|
||||
Reference in new issue
Block a user