2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

test: Fix Database Migrate test

- Use defaultsDeep instead of deepmerge
This commit is contained in:
Faris Ansari 2020-01-28 17:11:26 +05:30
parent 6e19cd76e2
commit 96b5bc091b
2 changed files with 10 additions and 9 deletions

View File

@ -41,10 +41,8 @@ describe('Database Migrate', () => {
let dbPath = '_migrate_test.db'; let dbPath = '_migrate_test.db';
server.init(); server.init();
let models = { let models = {
models: {
Person, Person,
Gender Gender
}
}; };
frappe.models = {}; frappe.models = {};
frappe.registerModels(models); frappe.registerModels(models);
@ -62,12 +60,15 @@ describe('Database Migrate', () => {
// check if tables were created // check if tables were created
assert.deepEqual(['Gender', 'Person'], tables); assert.deepEqual(['Gender', 'Person'], tables);
let fields = await frappe.db.sql('PRAGMA table_info(??)', 'Person') let fields = await frappe.db.sql('PRAGMA table_info(??)', 'Person');
// check if standard fields and model fields were created // check if standard fields and model fields were created
assert.equal(fields.length, 8); assert.equal(fields.length, 8);
assert.equal(fields.find(d => d.name === 'age').type, 'integer'); assert.equal(fields.find(d => d.name === 'age').type, 'integer');
let foreignKeys = await frappe.db.sql('PRAGMA foreign_key_list(??)', 'Person') let foreignKeys = await frappe.db.sql(
'PRAGMA foreign_key_list(??)',
'Person'
);
// check for foreign keys // check for foreign keys
assert.equal(foreignKeys.length, 1); assert.equal(foreignKeys.length, 1);
assert.equal(foreignKeys[0].from, 'gender'); assert.equal(foreignKeys[0].from, 'gender');

View File

@ -1,7 +1,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const chalk = require('chalk'); const chalk = require('chalk');
const deepmerge = require('deepmerge'); const defaultsDeep = require('lodash/defaultsDeep');
const logger = require('./logger'); const logger = require('./logger');
const frappeConf = 'frappe.conf.js'; const frappeConf = 'frappe.conf.js';
@ -30,7 +30,7 @@ function getAppConfig() {
} }
} }
const appConfig = require(path.resolve(getAppDir(), frappeConf)); const appConfig = require(path.resolve(getAppDir(), frappeConf));
return deepmerge(defaults, appConfig); return defaultsDeep(defaults, appConfig);
} }
function resolveAppDir(...args) { function resolveAppDir(...args) {