@@ -9,7 +9,12 @@ import { IDGenerationInfo, IDGenerator } from '../../src/execution/execution-opt
99import { ProjectOptions } from '../../src/project/project' ;
1010import { loadProjectFromDir } from '../../src/project/project-from-fs' ;
1111import { Log4jsLoggerProvider } from '../helpers/log4js-logger-provider' ;
12- import { createTempDatabase , initTestData , TestDataEnvironment } from './initialization' ;
12+ import {
13+ createTempDatabase ,
14+ getTempDatabaseConfig ,
15+ initTestData ,
16+ TestDataEnvironment ,
17+ } from './initialization' ;
1318import { ErrorWithCause } from '../../src/utils/error-with-cause' ;
1419import { InitTestDataContext } from './init-test-data-context' ;
1520import deepEqual = require( 'deep-equal' ) ;
@@ -55,8 +60,6 @@ export class RegressionSuite {
5560 private schema : GraphQLSchema | undefined ;
5661 private testDataEnvironment : TestDataEnvironment | undefined ;
5762 private _isSetUpClean = false ;
58- // TODO: this is ugly but provides a quick fix for things broken with the silentAdapter
59- // TODO: implement better regression test architecture for different db types
6063 private inMemoryDB : InMemoryDB = new InMemoryDB ( ) ;
6164 private databaseSpecifier : DatabaseSpecifier ;
6265 private readonly idGenerator = new PredictableIDGenerator ( ) ;
@@ -81,7 +84,6 @@ export class RegressionSuite {
8184 ? JSON . parse ( stripJsonComments ( readFileSync ( optionsPath , 'utf-8' ) ) )
8285 : { } ;
8386
84- this . inMemoryDB = new InMemoryDB ( ) ;
8587 this . idGenerator . resetToPhase ( 'init' ) ;
8688 const generalOptions : ProjectOptions = {
8789 processError : ( e ) => {
@@ -124,6 +126,7 @@ export class RegressionSuite {
124126 const adapter = await this . createAdapter ( debugLevelOptions ) ;
125127 this . schema = project . createSchema ( adapter ) ;
126128
129+ await this . clearDatabase ( ) ;
127130 await initAdapter . updateSchema ( initProject . getModel ( ) ) ;
128131
129132 const testDataJsonPath = resolve ( this . path , 'test-data.json' ) ;
@@ -168,6 +171,19 @@ export class RegressionSuite {
168171 this . _isSetUpClean = true ;
169172 }
170173
174+ private async clearDatabase ( ) {
175+ switch ( this . databaseSpecifier ) {
176+ case 'in-memory' :
177+ this . inMemoryDB = new InMemoryDB ( ) ;
178+ break ;
179+ case 'arangodb' :
180+ await createTempDatabase ( ) ;
181+ break ;
182+ default :
183+ throw new Error ( `Unknown database specifier: ${ this . databaseSpecifier } ` ) ;
184+ }
185+ }
186+
171187 private async createAdapter (
172188 context : ProjectOptions ,
173189 { isInitSchema = false } = { } ,
@@ -176,10 +192,9 @@ export class RegressionSuite {
176192 case 'in-memory' :
177193 return new InMemoryAdapter ( { db : this . inMemoryDB } , context ) ;
178194 case 'arangodb' :
179- const dbConnectionConfig = await createTempDatabase ( ) ;
180195 return new ArangoDBAdapter (
181196 {
182- ...dbConnectionConfig ,
197+ ...getTempDatabaseConfig ( ) ,
183198 // intentionally set low so we catch issues in tests
184199 // but silent schema uses higher limit because it's used in the setup
185200 queryMemoryLimit : isInitSchema
0 commit comments