fix for travis?

This commit is contained in:
Matteo Pagliazzi
2016-01-29 12:37:17 +01:00
parent bcfb52a16e
commit 80160597b0

View File

@@ -20,11 +20,17 @@ export async function checkExistence (collectionName, id) {
// Specifically helpful for the GET /groups tests,
// resets the db to an empty state and creates a tavern document
export async function resetHabiticaDB () {
console.log('calling resetHabiticaDatabase'); // eslint-disable-line
return new Promise((resolve, reject) => {
mongoose.connection.db.dropDatabase((dbErr) => {
if (dbErr) return reject(dbErr);
let groups = mongoose.connection.db.collection('groups');
// For some mysterious reason after a dropDatabase there can still be a group...
groups.count({_id: 'habitrpg'}, (err, count) => {
if (err) return reject(err);
if (count > 0) return resolve();
groups.insertOne({
_id: 'habitrpg',
chat: [],
@@ -39,6 +45,7 @@ export async function resetHabiticaDB () {
});
});
});
});
}
export async function updateDocument (collectionName, doc, update) {