blob: 7c12a4cc816719c7c84e769892b6c011afeacc70 [file] [log] [blame]
'use strict';
var helpers = require('../../helpers/integration');
var harness = helpers.harness(__filename);
var it = harness.it;
var nano = harness.locals.nano;
it('should be able to track updates in couch', function(assert) {
var called = false;
setTimeout(runTest, 100);
function runTest() {
nano.db.destroy('mydb', function() {
nano.updates(function(err, updates) {
if (called) {
return;
}
called = true;
//
// older couches
//
if (err && updates.error && updates.error === 'illegal_database_name') {
assert.expect(1);
assert.ok(updates.ok, 'db updates are not supported');
assert.end();
}
//
// new couches
//
else {
assert.equal(err, null, 'got root');
assert.ok(updates.ok, 'updates are ok');
assert.equal(updates.type, 'created', 'update was a create');
assert.equal(updates['db_name'], 'mydb', 'mydb was updated');
assert.end();
}
});
nano.db.create('mydb');
});
}
});