import TestSchemaProcessor from './TestSchemaProcessor' ; import Conversion from '../../src/Conversion' ; import DBAccess from '../../src/DBAccess' ; import DBVendors from '../../src/DBVendors' ; import DBAccessQueryResult from '../../src/DBAccessQueryResult' ; import IDBAccessQueryParams from '../../src/IDBAccessQueryParams' ; import { Test } from 'tape' ; /**
 * Checks if the schema exists.
 */ const hasSchemaCreated = async ( testSchemaProcessor ) : Promise < boolean > => { const sql = `SELECT EXISTS(SELECT schema_name FROM information_schema.schemata
         WHERE schema_name = '${ ( < Conversion > testSchemaProcessor . conversion ) . _schema }');` ; const params = { conversion : < Conversion > testSchemaProcessor . conversion , caller : 'SchemaProcessorTest::hasSchemaCreated' , sql : sql , vendor : DBVendors . PG , processExitOnError : false , shouldReturnClient : false } ; const result = await DBAccess . query ( params ) ; if ( result . error ) { await testSchemaProcessor . processFatalError ( result . error ) ; } return ! ! result . data . rows [ 0 ] . exists ; } ; /**
 * Tests schema creation.
 */ export default async ( testSchemaProcessor , tape ) : Promise < void > => { const schemaExists = await hasSchemaCreated ( testSchemaProcessor ) ; const numberOfPlannedAssertions = 1 ; const autoTimeoutMs = 3 * 1000 ; tape . plan ( numberOfPlannedAssertions ) ; tape . timeoutAfter ( autoTimeoutMs ) ; tape . equal ( schemaExists , true ) ; } ;