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

Commit 8cc1fbfb by Daniel Cohen

added tests [sequelize bin support options file + migration path]

1 parent 55646787
......@@ -18,7 +18,7 @@ var configuration = {
var loadDefaultOptions = function(path){
try{
options = require(path);
options = require(process.cwd()+'/'+path);
for (var key in options){
program[key] = options[key];
}
......@@ -179,7 +179,7 @@ program
.option('-u, --undo', 'Undo the last migration.')
.option('-f, --force', 'Forces the action to be done.')
.option('-c, --create-migration [migration-name]', 'Creates a new migration.')
.option('-p, --migrations-path', 'migration directory path.')
.option('-p, --migrations-path <migration-path>', 'migration directory path.')
.option('-U, --url <url>', 'Database url. An alternative to a config file')
.option('-o,--cli-options <options_file>', 'Specifies lib options from file.')
.option('--config <config_file>', 'Specifies alternate config file.')
......@@ -199,7 +199,7 @@ if(typeof program.config === 'string') {
}
if(typeof program.migrationsPath=== 'string') {
configuration.migrationsPath = program.migrationsPath
configuration.migrationsPath = program.migrationsPath;
}
if(typeof program.env === 'string') {
......
{
"configFile": "./config/database.json",
"migrationsPath": "./db/migrate"
}
......@@ -67,6 +67,17 @@ if (os.type().toLowerCase().indexOf('windows') === -1) {
})
})(['config', 'migrations'])
it("creates a custom migrations folder", function(done) {
exec("rm -rf ./*", { cwd: __dirname + '/tmp' }, function() {
exec("../../bin/sequelize --init -p ./db/migrate", { cwd: __dirname + '/tmp' }, function() {
exec("ls -ila", { cwd: __dirname + '/tmp' }, function(err, stdout) {
expect(stdout).to.include('db')
done()
})
})
})
})
it("creates a config.json file", function(done) {
exec("rm -rf ./*", { cwd: __dirname + '/tmp' }, function() {
exec("../../bin/sequelize --init", { cwd: __dirname + '/tmp' }, function() {
......@@ -93,6 +104,8 @@ if (os.type().toLowerCase().indexOf('windows') === -1) {
})
})
})
})
})
})(['--init', '-i'])
......@@ -435,6 +448,25 @@ if (os.type().toLowerCase().indexOf('windows') === -1) {
})
})
})(['--url', '-U'])
;(function(flags) {
flags.forEach(function(flag) {
describe(flag, function() {
it("using options file instead of cli switches", function(done) {
exec("rm -rf ./*", { cwd: __dirname + '/tmp' }, function() {
exec( "../../bin/sequelize --init "+flag+" ../../config/options.json" , { cwd: __dirname + '/tmp' }, function() {
exec("ls -ila", { cwd: __dirname + '/tmp' }, function(err, stdout) {
expect(stdout).to.include('db')
done()
})
})
})
})
});
})
})(['--cli-options', '-o'])
})
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!