Fixed test scripts
parent
3a8c426279
commit
01cd784a0e
|
@ -633,6 +633,15 @@ exports.indexOrders = (app, cb) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.fixProductDates = (products) => {
|
||||||
|
let index = 0;
|
||||||
|
products.forEach((product) => {
|
||||||
|
products[index].productAddedDate = new Date();
|
||||||
|
index++;
|
||||||
|
});
|
||||||
|
return products;
|
||||||
|
};
|
||||||
|
|
||||||
// start indexing products and orders
|
// start indexing products and orders
|
||||||
exports.runIndexing = (app) => {
|
exports.runIndexing = (app) => {
|
||||||
console.info(colors.yellow('Setting up indexes..'));
|
console.info(colors.yellow('Setting up indexes..'));
|
||||||
|
|
|
@ -3,8 +3,6 @@ const { initDb } = require('./db');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
console.log('__dirname', path.join(__dirname, '..', 'bin', 'testdata.json'));
|
|
||||||
|
|
||||||
const testData = fs.readFileSync(path.join(__dirname, '..', 'bin', 'testdata.json'), 'utf-8');
|
const testData = fs.readFileSync(path.join(__dirname, '..', 'bin', 'testdata.json'), 'utf-8');
|
||||||
const jsonData = JSON.parse(testData);
|
const jsonData = JSON.parse(testData);
|
||||||
|
|
||||||
|
@ -22,7 +20,7 @@ initDb(config.databaseConnectionString, (err, db) => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
db.users.insertMany(jsonData.users),
|
db.users.insertMany(jsonData.users),
|
||||||
db.customers.insertMany(jsonData.customers),
|
db.customers.insertMany(jsonData.customers),
|
||||||
db.products.insertMany(fixProductDates(jsonData.products)),
|
db.products.insertMany(common.fixProductDates(jsonData.products)),
|
||||||
db.menu.insertOne(jsonData.menu)
|
db.menu.insertOne(jsonData.menu)
|
||||||
])
|
])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -40,12 +38,3 @@ initDb(config.databaseConnectionString, (err, db) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Adds current date to product added date when smashing into DB
|
|
||||||
function fixProductDates(products){
|
|
||||||
let index = 0;
|
|
||||||
products.forEach((product) => {
|
|
||||||
products[index].productAddedDate = new Date();
|
|
||||||
index++;
|
|
||||||
});
|
|
||||||
return products;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue