33 lines
626 B
TypeScript
33 lines
626 B
TypeScript
|
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()
|
||
|
}
|
||
|
|
||
|
// TENANCY
|
||
|
|
||
|
doInTenant(task: any) {
|
||
|
return context.doInTenant(this.tenantId, () => {
|
||
|
return task()
|
||
|
})
|
||
|
}
|
||
|
|
||
|
getTenantId() {
|
||
|
try {
|
||
|
return context.getTenantId()
|
||
|
} catch (e) {
|
||
|
return this.tenantId!
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default DBTestConfiguration
|