Remove unused test context code

This commit is contained in:
Adria Navarro 2023-12-01 09:36:24 +01:00
parent fcb862c82f
commit fe0efc7539
1 changed files with 28 additions and 11 deletions

View File

@ -145,23 +145,19 @@ export async function doInTenant<T>(
} }
export async function doInAppContext<T>( export async function doInAppContext<T>(
appId: string | null, appId: string,
task: () => T task: () => T
): Promise<T> { ): Promise<T> {
if (!appId && !env.isTest()) { if (!appId) {
throw new Error("appId is required") throw new Error("appId is required")
} }
let updates: ContextMap const tenantId = getTenantIDFromAppID(appId)
if (!appId) { const updates: ContextMap = { appId }
updates = { appId: "" } if (tenantId) {
} else { updates.tenantId = tenantId
const tenantId = getTenantIDFromAppID(appId)
updates = { appId }
if (tenantId) {
updates.tenantId = tenantId
}
} }
return newContext(updates, task) return newContext(updates, task)
} }
@ -182,6 +178,27 @@ export async function doInIdentityContext<T>(
return newContext(context, task) return newContext(context, task)
} }
export async function doInAppMigrationContext<T>(
appId: string,
task: () => T
): Promise<T> {
if (!appId && !env.isTest()) {
throw new Error("appId is required")
}
let updates: ContextMap
if (!appId) {
updates = { appId: "" }
} else {
const tenantId = getTenantIDFromAppID(appId)
updates = { appId }
if (tenantId) {
updates.tenantId = tenantId
}
}
return newContext(updates, task)
}
export function getIdentity(): IdentityContext | undefined { export function getIdentity(): IdentityContext | undefined {
try { try {
const context = Context.get() const context = Context.get()