2023-02-13 12:57:30 +01:00
|
|
|
import "./mocks"
|
|
|
|
import * as structures from "./structures"
|
|
|
|
import * as testEnv from "./testEnv"
|
|
|
|
import * as context from "../../src/context"
|
|
|
|
|
|
|
|
class DBTestConfiguration {
|
|
|
|
tenantId: string
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
// db tests need to be multi tenant to prevent conflicts
|
|
|
|
testEnv.multiTenant()
|
|
|
|
this.tenantId = structures.tenant.id()
|
|
|
|
}
|
|
|
|
|
2023-02-21 18:13:24 +01:00
|
|
|
newTenant() {
|
|
|
|
this.tenantId = structures.tenant.id()
|
|
|
|
}
|
|
|
|
|
2023-02-13 12:57:30 +01:00
|
|
|
// TENANCY
|
|
|
|
|
|
|
|
doInTenant(task: any) {
|
|
|
|
return context.doInTenant(this.tenantId, () => {
|
|
|
|
return task()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
getTenantId() {
|
|
|
|
try {
|
|
|
|
return context.getTenantId()
|
|
|
|
} catch (e) {
|
|
|
|
return this.tenantId!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DBTestConfiguration
|