2c122a138d
* feat(multiregion): replace user replication * chore(multiregion): optimise replication * maybe it's this * postgres is fun * once more * chore(multiregion): only replicate test user creation during multiregion tests * feat: improved replicate_query logic * fix: minor * fix: starting issue * feat: included user create and delete specs to multiregion * feat: removed console logs * fix: user defaults * fix: multiregion test helper * fix: update scenarios for users * refactor(multiregion): swap replicateQuery concept to asMultiregionOperation (#5301) feat(multiregion): introduced asMultregionOperator, refactor test to user builder classes * chore: renamings * fix: remove comments * feat: remove user replication * refactor: simplified spec usages * chore: comments * chore: branches and favs * chore: more tests * chore: more tests * fix linting * fix tests * feat: dropping replication * refactor: moved project delete to service * fix: comment * feat: updateStreamFactory and updateProjectFacotry * deleteProjectFactory + replicateFactory * deleteWorkspaceFactory * fix: selector * fix: tests * fix tests, finished createStreamFactory * feat: simplify changes * fix: remove comment * fix: minor strucutres * fix: moveProjectToRegion * fix: moved branch creation outside of multiregion scope * fix: branch creation * fix: tests * fix: ci tests * fix: removed log form test * fix: on specs, no random regionKeys * review fixes * feat: workspace replciation * fix: mr comments * feat: removed test * fix: worksapce test creation * fix: mr issues * updated mutations * feat: drop workspace random defaults --------- Co-authored-by: Charles Driesler <chuck@speckle.systems>
32 lines
890 B
TypeScript
32 lines
890 B
TypeScript
import { db } from '@/db/knex'
|
|
import {
|
|
getRegisteredRegionClients,
|
|
getReplicationDbs
|
|
} from '@/modules/multiregion/utils/dbSelector'
|
|
import { isMultiRegionTestMode } from '@/test/speckle-helpers/regions'
|
|
import type { Knex } from 'knex'
|
|
|
|
export async function getAllRegisteredTestDbs(): Promise<[Knex, ...Knex[]]> {
|
|
if (!isMultiRegionTestMode()) return [db]
|
|
|
|
const regionClients = await getRegisteredRegionClients()
|
|
const regionDbs = Object.values(regionClients)
|
|
return [db, ...regionDbs]
|
|
}
|
|
|
|
export async function getTestRegionClientsForProject({
|
|
regionKey
|
|
}: {
|
|
regionKey?: string
|
|
}): Promise<[Knex, ...Knex[]]> {
|
|
if (!isMultiRegionTestMode()) return [db]
|
|
|
|
if (!regionKey) return [db]
|
|
const regionClients = await getRegisteredRegionClients()
|
|
|
|
const regionDb = regionClients[regionKey]
|
|
if (!regionDb) return [db]
|
|
|
|
return await getReplicationDbs({ regionKey })
|
|
}
|