Skip to content

Commit f3eadec

Browse files
committed
test(backend): update tenant service tests
1 parent 79422ed commit f3eadec

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

packages/backend/src/tenants/service.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ describe('Tenant Service', (): void => {
4444
let knex: Knex
4545

4646
beforeAll(async (): Promise<void> => {
47-
deps = initIocContainer(Config)
47+
deps = initIocContainer({
48+
...Config,
49+
dbSchema: 'tenant_service_test_schema'
50+
})
4851
appContainer = await createTestApp(deps)
4952
tenantService = await deps.use('tenantService')
5053
config = await deps.use('config')
@@ -53,15 +56,15 @@ describe('Tenant Service', (): void => {
5356
})
5457

5558
afterEach(async (): Promise<void> => {
56-
await truncateTables(knex, false)
59+
await truncateTables(knex, true)
5760
})
5861

5962
afterAll(async (): Promise<void> => {
6063
nock.cleanAll()
6164
await appContainer.shutdown()
6265
})
6366

64-
describe.skip('Tenant pagination', (): void => {
67+
describe('Tenant pagination', (): void => {
6568
describe('getPage', (): void => {
6669
getPageTests({
6770
createModel: () => createTenant(deps),
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Knex } from 'knex'
2-
import { Config } from '../config/app'
32

43
export async function truncateTable(
54
knex: Knex,
@@ -11,21 +10,18 @@ export async function truncateTable(
1110

1211
export async function truncateTables(
1312
knex: Knex,
14-
doSeedOperatorTenant = true
13+
truncateTenants = false
1514
): Promise<void> {
1615
const ignoreTables = [
1716
'knex_migrations',
1817
'knex_migrations_lock',
1918
'knex_migrations_backend',
20-
'knex_migrations_backend_lock'
19+
'knex_migrations_backend_lock',
20+
...(truncateTenants ? [] : ['tenants']) // So we don't delete operator tenant
2121
]
2222
const tables = await getTables(knex, ignoreTables)
2323
const RAW = `TRUNCATE TABLE "${tables}" RESTART IDENTITY`
2424
await knex.raw(RAW)
25-
26-
if (doSeedOperatorTenant) {
27-
await seedOperatorTenant(knex)
28-
}
2925
}
3026

3127
async function getTables(knex: Knex, ignoredTables: string[]): Promise<string> {
@@ -39,9 +35,3 @@ async function getTables(knex: Knex, ignoredTables: string[]): Promise<string> {
3935
.filter(Boolean)
4036
.join('","')
4137
}
42-
43-
export async function seedOperatorTenant(knex: Knex): Promise<void> {
44-
await knex
45-
.table('tenants')
46-
.insert({ id: Config.operatorTenantId, apiSecret: Config.adminApiSecret })
47-
}

0 commit comments

Comments
 (0)