Before we create a db instance we check for testing flag is set and then use the :MEMORY: database for a anonymous db instance.
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
const configuration = require('src/config/configuration').getInstance();
|
const configuration = require('src/config/configuration').getInstance();
|
||||||
const SqliteDatabase = require('src/database/sqliteDatabase');
|
const SqliteDatabase = require('src/database/sqliteDatabase');
|
||||||
|
|
||||||
const database = new SqliteDatabase(configuration.get('database', 'host'));
|
const host = process.env.TESTING ? ':memory:' : configuration.get('database', 'host');
|
||||||
|
const database = new SqliteDatabase(host);
|
||||||
/**
|
/**
|
||||||
* This module establishes a connection to the database
|
* This module establishes a connection to the database
|
||||||
* specified in the confgiuration file. It tries to setup
|
* specified in the confgiuration file. It tries to setup
|
||||||
@@ -10,7 +10,6 @@ const database = new SqliteDatabase(configuration.get('database', 'host'));
|
|||||||
* If the tables already exists, it simply proceeds.
|
* If the tables already exists, it simply proceeds.
|
||||||
*/
|
*/
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => database.connect())
|
|
||||||
.then(() => database.setUp());
|
.then(() => database.setUp());
|
||||||
|
|
||||||
module.exports = database;
|
module.exports = database;
|
||||||
|
|||||||
Reference in New Issue
Block a user