server/node_modules/cradle/test/helpers/seed.js in vulcan-0.6.1 vs server/node_modules/cradle/test/helpers/seed.js in vulcan-0.7.0
- old
+ new
@@ -9,31 +9,32 @@
var seed = exports;
seed.createDatabase = function (name, callback) {
request({
method: 'PUT',
- url: 'http://127.0.0.1:5984/' + name
+ url: 'http://127.0.0.1:5984/' + encodeURIComponent(name)
}, callback);
};
seed.deleteDatabase = function (name, callback) {
request({
method: 'DELETE',
- url: 'http://127.0.0.1:5984/' + name
+ url: 'http://127.0.0.1:5984/' + encodeURIComponent(name)
}, callback);
};
seed.seedDatabase = function (name, callback) {
- seed.deleteDatabase(name, function (err) {
+ console.log('Seeding ' + name);
+ seed.deleteDatabase(name, function (err, res, body) {
if (!databases[name]) {
return callback(err);
}
function putDoc (doc, next) {
request({
method: 'PUT',
- url: 'http://127.0.0.1:5984/' + name + '/' + doc._id,
+ url: 'http://127.0.0.1:5984/' + encodeURIComponent(name) + '/' + doc._id,
body: JSON.stringify(doc)
}, next);
}
seed.createDatabase(name, function () {
@@ -51,6 +52,14 @@
"should respond with no errors": function (err) {
assert.isTrue(!err);
}
}
}
-};
+};
+
+if (!module.parent) {
+ async.forEachSeries(Object.keys(databases), seed.seedDatabase, function (err) {
+ return err
+ ? console.log('Error seeding database: ' + err.message)
+ : console.log('Database seed completed.');
+ });
+}
\ No newline at end of file