From 50e2d3c68697518f22653e24bcfae6c340e181a9 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 26 Apr 2022 15:26:56 +0100 Subject: [PATCH] Test fixes --- .../routes/tests/utilities/TestFunctions.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/routes/tests/utilities/TestFunctions.ts b/packages/server/src/api/routes/tests/utilities/TestFunctions.ts index c86a980d2c..a34527e8f2 100644 --- a/packages/server/src/api/routes/tests/utilities/TestFunctions.ts +++ b/packages/server/src/api/routes/tests/utilities/TestFunctions.ts @@ -2,6 +2,7 @@ import * as rowController from "../../../controllers/row" import * as appController from "../../../controllers/application" import { AppStatus } from "../../../../db/utils" import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/roles" +import { doInTenant } from "@budibase/backend-core/tenancy" import { TENANT_ID } from "../../../../tests/utilities/structures" import { getAppDB, doInAppContext } from "@budibase/backend-core/context" import * as env from "../../../../environment" @@ -32,17 +33,19 @@ export const getAllTableRows = async (config: any) => { } export const clearAllApps = async (tenantId = TENANT_ID) => { - const req: any = { query: { status: AppStatus.DEV }, user: { tenantId } } - await appController.fetch(req) - const apps = req.body - if (!apps || apps.length <= 0) { - return - } - for (let app of apps) { - const { appId } = app - const req = new Request(null, { appId }) - await runRequest(appId, appController.destroy, req) - } + await doInTenant(tenantId, async () => { + const req: any = { query: { status: AppStatus.DEV }, user: { tenantId } } + await appController.fetch(req) + const apps = req.body + if (!apps || apps.length <= 0) { + return + } + for (let app of apps) { + const { appId } = app + const req = new Request(null, { appId }) + await runRequest(appId, appController.destroy, req) + } + }) } export const clearAllAutomations = async (config: any) => {