Skip to content

Commit

Permalink
Merge pull request #42 from w3c/test-cleanup-db
Browse files Browse the repository at this point in the history
Clean up database before running test suite
  • Loading branch information
tripu authored Aug 4, 2016
2 parents 8f3c33d + afbefe9 commit 5f9342c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/server-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,30 @@ function mockPRStatus(pr, status, description) {
describe('Server starts and responds with no login', function () {
var app, req, http;

before(function () {
before(function (done) {
http = server.run(config, transporter);
app = server.app;
req = request(app);

// database clean-up
store = new Store(config);
/* Delete non-design documents in a database. */
store.db.all(function(err, doc) {
/* Loop through all documents. */
var total = doc.length;
for(var i = 0; i < doc.length; i++) {
/* Don't delete design documents. */
if(doc[i].id.indexOf("_design") == -1) {
store.db.remove(doc[i].id, doc[i].value.rev, function(err, doc) {
total--;
if (!total) done();
});
} else {
total--;
if (!total) done();
}
}
});
});

after(function (done) {
Expand Down

0 comments on commit 5f9342c

Please sign in to comment.