File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ export class TestDatabaseModule {
3131 }
3232
3333 async reset ( ) : Promise < void > {
34+ this . entityManager . clear ( ) ;
35+ return this . resetInContext ( ) ;
36+ }
37+
38+ @UseRequestContext ( )
39+ private async resetInContext ( ) : Promise < void > {
3440 const dbName = StaticSettings . getService ( ) . getDatabaseConnectionInformation ( ) . dbName ;
3541 const connection = this . orm . em . getConnection ( ) ;
3642 const allTables = await connection . execute ( `SHOW TABLES FROM \`${ dbName } \`` ) ;
@@ -68,6 +74,6 @@ export class TestDatabaseModule {
6874 }
6975
7076 private async generateMocks ( ) {
71- await populateMockLists ( this . entityManager ) ;
77+ await populateMockLists ( ) ;
7278 }
7379}
Original file line number Diff line number Diff line change 1- import { EntityManager } from '@mikro-orm/core' ;
21import { DateTime } from 'luxon' ;
32import { Role } from 'shared/model/Role' ;
43import { ScheincriteriaIdentifier } from 'shared/model/ScheinCriteria' ;
@@ -51,7 +50,7 @@ function clearArray(array: any[]): void {
5150 array . splice ( 0 , array . length ) ;
5251}
5352
54- export async function populateMockLists ( em : EntityManager ) : Promise < void > {
53+ export async function populateMockLists ( ) : Promise < void > {
5554 clearArray ( MOCKED_USERS ) ;
5655 MOCKED_USERS . push (
5756 new User ( {
@@ -322,16 +321,10 @@ export async function populateMockLists(em: EntityManager): Promise<void> {
322321 clearArray ( MOCKED_SETTINGS_DOCUMENT ) ;
323322 MOCKED_SETTINGS_DOCUMENT . push ( Setting . fromDTO ( ) ) ;
324323
325- await adjustMocksWithAdditionalInformation ( em ) ;
324+ await adjustMocksWithAdditionalInformation ( ) ;
326325}
327326
328- async function adjustMocksWithAdditionalInformation ( em : EntityManager ) : Promise < void > {
329- for ( const entities of ENTITY_LISTS ) {
330- em . persist ( entities ) ;
331- }
332-
333- await em . flush ( ) ;
334-
327+ async function adjustMocksWithAdditionalInformation ( ) : Promise < void > {
335328 MOCKED_USERS [ 3 ] . tutorialsToCorrect . add ( MOCKED_TUTORIALS [ 0 ] , MOCKED_TUTORIALS [ 2 ] ) ;
336329
337330 MOCKED_TUTORIALS [ 1 ] . tutor = MOCKED_USERS [ 2 ] ;
You can’t perform that action at this time.
0 commit comments