2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 11:55:46 +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';
server.init();
let models = {
models: {
Person,
Gender
}
Person,
Gender
};
frappe.models = {};
frappe.registerModels(models);
@ -62,12 +60,15 @@ describe('Database Migrate', () => {
// check if tables were created
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
assert.equal(fields.length, 8);
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
assert.equal(foreignKeys.length, 1);
assert.equal(foreignKeys[0].from, 'gender');

View File

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