| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- const { assert, expect, should } = require('chai');
- const db = require('../lib/db');
- const paths = require('../config/paths.json');
- const settings = require('../config/settings.json'); // get the settings
- const dirs = Object.keys(paths); // get a list of the paths from the keys
- const defaults = settings.defaults || {}; // load the defaults
- describe('DB tests', function() {
- let database, options, dir;
- let payload = {
- "input": "/some/path/to/a/file",
- "output": "/another/path/to/a/file",
- "status": "",
- "date": new Date()
- };
- before(async function() {
- dir = dirs[0];
- options = Object.assign({}, defaults, paths[dir]); // baseline the options
- database = db.connect(dir,options);
- });
- it('set', async function() {
- const result = await db.set(database, payload);
- expect(result).to.be.an('object');
- expect(result.input).to.equal('/some/path/to/a/file');
- });
- it('update', async function() {
- payload.status = 'updated';
- const result = await db.set(database, '/some/path/to/a/file', payload);
- expect(result).to.be.an('object');
- expect(result.status).to.equal('updated');
- });
- it('find', async function() {
- const result = await db.find(database,'/some/path/to/a/file');
- expect(result).to.be.an('object');
- expect(result.input).to.equal('/some/path/to/a/file');
- });
- it('remove', async function() {
- await db.remove(database,'/some/path/to/a/file');
- });
- });
|