Fix broken tests
This commit is contained in:
parent
36338ccdbe
commit
d532ac82f0
@ -1,15 +1,10 @@
|
|||||||
import {Namespace} from 'cls-hooked'
|
import loggerFactory from '@rondo.dev/logger'
|
||||||
|
import { Namespace } from 'cls-hooked'
|
||||||
import shortid from 'shortid'
|
import shortid from 'shortid'
|
||||||
import {
|
import { Connection, EntityManager, EntitySchema, ObjectType, Repository } from 'typeorm'
|
||||||
ENTITY_MANAGER, ITransactionManager, TRANSACTION_ID
|
import { ENTITY_MANAGER, ITransactionManager, TRANSACTION_ID } from './ITransactionManager'
|
||||||
} from './ITransactionManager'
|
|
||||||
import {
|
const log = loggerFactory.getLogger('db')
|
||||||
Connection,
|
|
||||||
EntityManager,
|
|
||||||
EntitySchema,
|
|
||||||
ObjectType,
|
|
||||||
Repository,
|
|
||||||
} from 'typeorm'
|
|
||||||
|
|
||||||
export type TConnectionGetter = () => Connection
|
export type TConnectionGetter = () => Connection
|
||||||
|
|
||||||
@ -40,9 +35,11 @@ export class TransactionManager implements ITransactionManager {
|
|||||||
async doInTransaction<T>(fn: (em: EntityManager) => Promise<T>) {
|
async doInTransaction<T>(fn: (em: EntityManager) => Promise<T>) {
|
||||||
const alreadyInTransaction = this.isInTransaction()
|
const alreadyInTransaction = this.isInTransaction()
|
||||||
if (alreadyInTransaction) {
|
if (alreadyInTransaction) {
|
||||||
|
log.info('doInTransaction: reusing existing transaction')
|
||||||
return await fn(this.getEntityManager())
|
return await fn(this.getEntityManager())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info('doInTransaction: starting new transaction')
|
||||||
return this.doInNewTransaction(fn)
|
return this.doInNewTransaction(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user