Skip to content

Commit

Permalink
test adduser with the API
Browse files Browse the repository at this point in the history
  • Loading branch information
Filirom1 committed Feb 5, 2013
1 parent 259b87a commit 77b2cfb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/common.js
Expand Up @@ -39,9 +39,14 @@ exports.addUser = function(user, cb){
cb = user;
user = {};
}
app.db.exec('addUser', _(user).defaults(exports.defaultUser), function(err, results){
exports.addSuperUser(exports.superUser, function(err){
if(err) return cb(err);
cb(null, results.rows[0]);
var base = 'https://:' + exports.superUser.apiKey + '@localhost:5000';
user = _(user).defaults(exports.defaultUser);
request.post({
url: base + '/internal/user',
json: user
}, cb);
});
};

Expand All @@ -51,6 +56,7 @@ exports.addSuperUser = function(user, cb){
user = {};
}
app.db.exec('addUser', _(user).defaults(exports.superUser), function(err, results){
if(err && /Sorry, a user with that email address already exists/.test(err.error)) return cb();
if(err) return cb(err);
cb(null, results.rows[0]);
});
Expand Down

0 comments on commit 77b2cfb

Please sign in to comment.