This commit is contained in:
adrinr 2023-02-03 11:28:27 +00:00
parent 9936d03e27
commit 5d58fc5948
6 changed files with 11 additions and 6 deletions

View File

@ -14,7 +14,7 @@ describe("utils", () => {
}) })
it("should call platform logout", async () => { it("should call platform logout", async () => {
await doInTenant(`tenant-${newid()}`, async () => { await doInTenant(structures.tenant.name(), async () => {
const ctx = structures.koa.newContext() const ctx = structures.koa.newContext()
await utils.platformLogout({ ctx, userId: "test" }) await utils.platformLogout({ ctx, userId: "test" })
expect(events.auth.logout).toBeCalledTimes(1) expect(events.auth.logout).toBeCalledTimes(1)

View File

@ -8,3 +8,4 @@ export * as apps from "./apps"
export * as koa from "./koa" export * as koa from "./koa"
export * as licenses from "./licenses" export * as licenses from "./licenses"
export * as plugins from "./plugins" export * as plugins from "./plugins"
export * as tenant from "./tenants"

View File

@ -0,0 +1,5 @@
import { newid } from "../../../src/newid"
export function name() {
return `tenant-${newid()}`
}

View File

@ -1,4 +1,4 @@
import { generator, mocks } from "@budibase/backend-core/tests" import { generator, mocks, structures } from "@budibase/backend-core/tests"
// init the licensing mock // init the licensing mock
import * as pro from "@budibase/pro" import * as pro from "@budibase/pro"
@ -149,7 +149,7 @@ class TestConfiguration {
async init(appName = newid()) { async init(appName = newid()) {
this.defaultUserValues = this.populateDefaultUserValues() this.defaultUserValues = this.populateDefaultUserValues()
if (context.isMultiTenant()) { if (context.isMultiTenant()) {
this.tenantId = `tenant-${newid()}` this.tenantId = structures.tenant.name()
} }
if (!this.started) { if (!this.started) {

View File

@ -20,7 +20,6 @@ import {
auth, auth,
constants, constants,
env as coreEnv, env as coreEnv,
utils,
DEFAULT_TENANT_ID, DEFAULT_TENANT_ID,
} from "@budibase/backend-core" } from "@budibase/backend-core"
import structures, { TENANT_ID, CSRF_TOKEN } from "./structures" import structures, { TENANT_ID, CSRF_TOKEN } from "./structures"
@ -136,7 +135,7 @@ class TestConfiguration {
async beforeAll() { async beforeAll() {
try { try {
this.#tenantId = `tenant-${utils.newid()}` this.#tenantId = structures.tenant.name()
// Running tests in parallel causes issues creating the globaldb twice. This ensures the db is properly created before starting // Running tests in parallel causes issues creating the globaldb twice. This ensures the db is properly created before starting
await retry(async () => await this.createDefaultUser()) await retry(async () => await this.createDefaultUser())

View File

@ -100,7 +100,7 @@ export class UserAPI extends TestAPI {
request = { request = {
email: structures.email(), email: structures.email(),
password: generator.string(), password: generator.string(),
tenantId: `tenant-${structures.uuid()}`, tenantId: structures.tenant.name(),
} }
} }
const res = await this.request const res = await this.request