Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('process() - update (mtime changed and hash changed)', () => {
const box = newBox('test');
const name = 'a.txt';
const path = pathFn.join(box.base, name);
const cacheId = 'test/' + name;
const processor = sinon.spy();
box.addProcessor(processor);
return Promise.all([
fs.writeFile(path, 'a'),
box.Cache.insert({
_id: cacheId,
modified: 0,
hash: util.hash('b').toString('hex')
})
]).then(() => box.process()).then(() => {
const file = processor.args[0][0];
file.type.should.eql('update');
file.path.should.eql(name);
}).finally(() => fs.rmdir(box.base));
});
return fs.writeFile(path, 'a').then(() => fs.stat(path)).then(stats => box.Cache.insert({
_id: cacheId,
modified: 0,
hash: util.hash('a').toString('hex')
})).then(() => box.process()).then(() => {
const file = processor.args[0][0];