Skip to content

Commit

Permalink
(456) - Cleanup during test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
daleharvey committed Mar 30, 2013
1 parent 22b5ac1 commit 861bd19
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 88 deletions.
8 changes: 3 additions & 5 deletions tests/test.all_docs.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true, makeDocs: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -26,12 +27,9 @@ adapters.map(function(adapter) {
qunit('all_docs: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

var origDocs = [
Expand Down
8 changes: 3 additions & 5 deletions tests/test.attachments.js
Expand Up @@ -2,6 +2,7 @@
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true, makeDocs: false */
/*globals readBlob: false, makeBlob: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand Down Expand Up @@ -30,12 +31,9 @@ adapters.map(function(adapter) {
qunit('attachments: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

var binAttDoc = {
Expand Down
9 changes: 3 additions & 6 deletions tests/test.basics.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -24,12 +25,9 @@ adapters.map(function(adapter) {
qunit("basics: " + adapter, {
setup: function() {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest("Create a pouch", 1, function() {
Expand Down Expand Up @@ -60,7 +58,6 @@ adapters.map(function(adapter) {
});

asyncTest("Modify a doc", 3, function() {
console.info('testing: Modify a doc');
initTestDB(this.name, function(err, db) {
ok(!err, 'opened the pouch');
db.post({test: "somestuff"}, function (err, info) {
Expand Down
8 changes: 3 additions & 5 deletions tests/test.bulk_docs.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true, makeDocs: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -27,12 +28,9 @@ adapters.map(function(adapter) {
qunit('bulk_docs: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

var authors = [
Expand Down
8 changes: 3 additions & 5 deletions tests/test.changes.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -26,12 +27,9 @@ adapters.map(function(adapter) {
QUnit.module("changes: " + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest("All changes", function () {
Expand Down
8 changes: 3 additions & 5 deletions tests/test.compaction.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true, putTree: false */
/*globals ajax: true, LevelPouch: true, makeDocs: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -25,12 +26,9 @@ adapters.map(function(adapter) {
qunit('compaction: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest('Compation document with no revisions to remove', function() {
Expand Down
8 changes: 3 additions & 5 deletions tests/test.conflicts.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -26,12 +27,9 @@ adapters.map(function(adapter) {
qunit('conflicts: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest('Testing conflicts', function() {
Expand Down
8 changes: 3 additions & 5 deletions tests/test.design_docs.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -26,12 +27,9 @@ adapters.map(function(adapter) {
qunit("design_docs: " + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

var doc = {
Expand Down
8 changes: 3 additions & 5 deletions tests/test.get.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false, putTree: false, putBranch: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true, makeDocs: false, strictEqual: false, notStrictEqual: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -26,12 +27,9 @@ adapters.map(function(adapter) {
qunit('get: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

var origDocs = [
Expand Down
8 changes: 3 additions & 5 deletions tests/test.gql.js
@@ -1,5 +1,6 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -23,12 +24,9 @@ adapters.map(function(adapter) {
qunit('gql: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest("Test select *", function() {
Expand Down
9 changes: 3 additions & 6 deletions tests/test.issue221.js
@@ -1,6 +1,7 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false, strictEqual: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals cleanupTestDatabases: false */

"use strict";

Expand Down Expand Up @@ -30,13 +31,9 @@ adapters.map(function(adapters) {
setup: function() {
this.local = generateAdapterUrl(adapters[0]);
this.remote = generateAdapterUrl(adapters[1]);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.local);
Pouch.destroy(this.remote);
}
}
teardown: cleanupTestDatabases
});

var doc = { _id: '0', integer: 0 };
Expand Down
9 changes: 3 additions & 6 deletions tests/test.replication.js
@@ -1,5 +1,6 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, initDBPair: false, openTestDB: false, putAfter: false */
/*globals cleanupTestDatabases: false */

"use strict";

Expand Down Expand Up @@ -33,13 +34,9 @@ adapters.map(function(adapters) {
setup : function () {
this.name = generateAdapterUrl(adapters[0]);
this.remote = generateAdapterUrl(adapters[1]);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
Pouch.destroy(this.remote);
}
}
teardown: cleanupTestDatabases
});

var docs = [
Expand Down
9 changes: 4 additions & 5 deletions tests/test.revs_diff.js
@@ -1,10 +1,12 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false */
/*globals cleanupTestDatabases: false */

"use strict";

var adapters = ['http-1', 'local-1'];
var qunit = module;
var LevelPouch;

// if we are running under node.js, set things up
// a little differently, and only test the leveldb adapter
Expand All @@ -24,12 +26,9 @@ adapters.map(function(adapter) {
qunit("revs diff:" + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest("Test revs diff", function() {
Expand Down
9 changes: 4 additions & 5 deletions tests/test.spatial.js
@@ -1,10 +1,12 @@
/*globals initTestDB: false, emit: true, generateAdapterUrl: false */
/*globals PERSIST_DATABASES: false, Spatial: false */
/*globals cleanupTestDatabases: false */

"use strict";

var adapters = ['local-1', 'http-1'];
var qunit = module;
var LevelPouch;

// if we are running under node.js, set things up
// a little differently, and only test the leveldb adapter
Expand All @@ -24,12 +26,9 @@ adapters.map(function(adapter) {
qunit('spatial: ' + adapter, {
setup : function () {
this.name = generateAdapterUrl(adapter);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

// some geometries are based on the GeoJSON specification
Expand Down
9 changes: 3 additions & 6 deletions tests/test.taskqueue.js
Expand Up @@ -2,6 +2,7 @@
/*globals PERSIST_DATABASES: false, initDBPair: false, utils: true */
/*globals ajax: true, LevelPouch: true */
/*globals Pouch: true, QUnit, uuid, asyncTest, ok, start*/
/*globals cleanupTestDatabases: false */

"use strict";

Expand All @@ -24,13 +25,9 @@ adapters.map(function(adapter) {
qunit("taskqueue: " + adapter, {
setup: function() {
this.name = generateAdapterUrl(adapter);
Pouch.destroy(this.name);
Pouch.enableAllDbs = true;
},
teardown: function() {
if (!PERSIST_DATABASES) {
Pouch.destroy(this.name);
}
}
teardown: cleanupTestDatabases
});

asyncTest("Add a doc", 1, function() {
Expand Down

0 comments on commit 861bd19

Please sign in to comment.