不要怂,就是干,撸起袖子干!

Commit 78d1f617 by Sascha Depold

test for on('failure', ...)

1 parent 62dfc1a5
Showing with 11 additions and 1 deletions
......@@ -22,6 +22,7 @@ Query.prototype.run = function(query) {
client.query(query, function(err, results, fields) {
err ? self.onFailure(err) : self.onSuccess(query, results, fields)
})
client.on('error', function(err) { self.onFailure(err) })
client.end()
return this
......
......@@ -4,11 +4,19 @@ var assert = require("assert")
, sequelize = new Sequelize(config.database, config.username, config.password)
module.exports = {
'sync should work': function(beforeExit) {
'sync should work with correct database config': function(beforeExit) {
var User = sequelize.define('User', {
name: Sequelize.STRING,
bio: Sequelize.TEXT
})
User.sync().on('success', beforeExit)
},
'sync should fail with incorrect database config': function(beforeExit) {
var s = new Sequelize('foo', 'bar', null)
var User = s.define('User', {
name: Sequelize.STRING,
bio: Sequelize.TEXT
})
User.sync().on('failure', beforeExit)
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!