diff --git a/packages/core/src/qedix-tests/authority-gate-positive-test.ts b/packages/core/src/qedix-tests/authority-gate-positive-test.ts new file mode 100644 index 00000000000..cc229b616a8 --- /dev/null +++ b/packages/core/src/qedix-tests/authority-gate-positive-test.ts @@ -0,0 +1,33 @@ +type DbClient = { + connection: { + findFirst(args: unknown): Promise<{ id: string; value: number } | null>; + update(args: unknown): Promise; + }; +}; + +export async function updateConnectionWithoutTenantScope( + db: DbClient, + connectionId: string, + nextValue: number +) { + const existing = await db.connection.findFirst({ + where: { + id: connectionId, + }, + }); + + if (!existing) { + return null; + } + + await db.connection.update({ + where: { + id: existing.id, + }, + data: { + value: existing.value + nextValue, + }, + }); + + return { success: true, data: { connectionId: existing.id } }; +}