MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / countTenantRows

Function countTenantRows

apps/cloud/src/db/org-deletion.test.ts:161–174  ·  view source on GitHub ↗
(db: DrizzleDb, tenant: string)

Source from the content-addressed store, hash-verified

159] as const;
160
161const countTenantRows = async (db: DrizzleDb, tenant: string): Promise<number> => {
162 let total = 0;
163 for (const table of TENANT_TABLES) {
164 const rows = await db.select().from(table).where(eq(table.tenant, tenant));
165 total += rows.length;
166 }
167 // Count by the exact namespaces `seedTenant` inserts. Matching on a `%tenant%`
168 // LIKE here would reintroduce the very wildcard hazard under test.
169 const blobs = await db
170 .select()
171 .from(blob)
172 .where(inArray(blob.namespace, [`o:${tenant}/plugin`, `u:${tenant}:subject/plugin`]));
173 return total + blobs.length;
174};
175
176describe("purgeOrganizationData", () => {
177 it("removes all of one org's data and leaves other orgs untouched", async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected