Fixes shared updates for ci (hopefully)
diff --git a/.travis.yml b/.travis.yml
index 446e28d..b58456a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,4 +14,5 @@
os:
- linux
- osx
-
+before_script:
+ - npm update -g npm
diff --git a/tests/fixtures/shared/updates.json b/tests/fixtures/shared/updates.json
index 5c3f45b..3aa6f47 100644
--- a/tests/fixtures/shared/updates.json
+++ b/tests/fixtures/shared/updates.json
@@ -1,13 +1,17 @@
[
- { "method" : "put"
+ { "method" : "delete"
, "path" : "/mydb"
- , "status" : 201
, "response" : "{ \"ok\": true }"
}
, { "method" : "get"
, "path" : "/_db_updates"
, "response" : "{\"ok\":true,\"type\":\"created\",\"db_name\":\"mydb\"}"
}
+, { "method" : "put"
+ , "path" : "/mydb"
+ , "status" : 201
+ , "response" : "{ \"ok\": true }"
+ }
, { "method" : "delete"
, "path" : "/mydb"
, "response" : "{ \"ok\": true }"
diff --git a/tests/integration/shared/updates.js b/tests/integration/shared/updates.js
index ec50e94..8bbff78 100644
--- a/tests/integration/shared/updates.js
+++ b/tests/integration/shared/updates.js
@@ -8,36 +8,42 @@
it('should be able to track updates in couch', function(assert) {
var called = false;
- setImmediate(runTest);
+ function getUpdates() {
+ nano.updates(function(err, updates) {
+ if (called) {
+ return;
+ }
+ called = true;
- 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');
+ //
+ // 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();
+ }
});
+
+ setTimeout(function() { nano.db.create('mydb'); }, 50);
}
+
+ nano.db.destroy('mydb', getUpdates);
+});
+
+it('should destroy mydb', function(assert) {
+ nano.db.destroy('mydb', function(err) {
+ assert.equal(err, null, 'no errors');
+ assert.end();
+ });
});