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

Commit aff5f1c6 by Sascha Depold

test that migrations are correctly undone

1 parent 35cf11c9
Showing with 48 additions and 10 deletions
......@@ -209,20 +209,30 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
;(function(flags) {
flags.forEach(function(flag) {
var prepare = function(callback) {
var execBinary = function(callback, _flag) {
_flag = _flag || flag
var dialect = Support.getTestDialect()
, config = require(__dirname + '/config/config.js')
config.sqlite.storage = __dirname + "/tmp/test.sqlite"
config = _.extend(config, config[dialect], { dialect: dialect })
exec("echo '" + JSON.stringify(config) + "' > config/config.json", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("../../bin/sequelize " + _flag, { cwd: __dirname + "/tmp" }, callback)
})
}
var prepare = function(callback, options) {
options = options || {}
exec("rm -rf ./*", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("../../bin/sequelize --init", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("cp ../assets/migrations/*-createPerson.js ./migrations/", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("cat ../support.js|sed s,/../,/../../, > ./support.js", { cwd: __dirname + '/tmp' }, function(error, stdout) {
var dialect = Support.getTestDialect()
, config = require(__dirname + '/config/config.js')
config.sqlite.storage = __dirname + "/tmp/test.sqlite"
config = _.extend(config, config[dialect], { dialect: dialect })
exec("echo '" + JSON.stringify(config) + "' > config/config.json", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("../../bin/sequelize " + flag, { cwd: __dirname + "/tmp" }, callback)
})
if (!options.skipExecBinary) {
execBinary(callback, options.flag)
}
})
})
})
......@@ -265,6 +275,34 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
done()
}.bind(this))
})
it("is correctly undoing a migration if they have been done yet", function(done) {
var sequelize = this.sequelize
if (this.sequelize.options.dialect === 'sqlite') {
var options = this.sequelize.options
options.storage = __dirname + "/tmp/test.sqlite"
sequelize = new Support.Sequelize("", "", "", options)
}
prepare(function() {
sequelize.getQueryInterface().showAllTables().success(function(tables) {
tables = tables.sort()
expect(tables).to.have.length(2)
expect(tables[0]).to.equal("Person")
execBinary(function(err, output) {
sequelize.getQueryInterface().showAllTables().success(function(tables) {
expect(tables).to.have.length(1)
expect(tables[0]).to.equal("SequelizeMeta")
done()
})
})
})
}.bind(this), { flag: '-m' })
})
})
})
})(['--migrate --undo', '-mu'])
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!