Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function (data) {
test.equal('value', data, 'The get() should return the right value from the secondary instance')
test.equals(1, cache2.getRequestCounts()['get'], 'The secondary cache should get one get()')
// the following is a fragile test... any better ideas?
return Q.delay(20)
})
.then(function () {
function onScanFinished() {
// remove all records which are not found during scan
var scanPath = self.scanPath;
self.scanPath = null;
self.logger.info('MusicLibrary: remove all unaffected items at ' + scanPath);
// wait for debounceTime, so we make sure all records are saved/updated
return libQ.delay(config.debounceTime * 2).then(function() { // we multiply by 2 to make sure cache is processed
return self.model.AudioMetadata.destroy({
where: {
[Sequelize.Op.and]: {
// It's not clear, but 'endsWith' produce "LIKE 'hat%'" condition
// http://docs.sequelizejs.com/manual/querying.html#operators
location: {[Sequelize.Op.endsWith]: scanPath + path.sep},
updatedAt: {[Sequelize.Op.lt]: self.scanStartedAt}
}
}
});
}).then(function(numDeleted) {
self.logger.info('MusicLibrary: removed all unaffected items:', numDeleted);
return self.backupDatabase();
});
}
FakeCache.prototype.get = function (key) {
if (this._failureCount > 0) return this._fakeFail('get')
this._logger.fine('FakeCache - get', key)
var self = this
// Add an artificial delay to mimic real world cache latency.
return Q.delay(this._latencyMs)
.then(function actualGet() {
self._requestCounts.get += 1
return Q.resolve(self._getInternal(key))
})
}
this.graph.add('throws-first', function () {
test.ok("First important node ran")
failCount++
return Q.delay(500)
.then(function () {
throw err
})
})
function testDelay(delayMs) {
return Q.delay(true, delayMs)
}
.then(function () {
return Q.delay(1050)
})
.then(function (val) {