-
-
Notifications
You must be signed in to change notification settings - Fork 527
/
options.test.js
67 lines (61 loc) · 2.15 KB
/
options.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const Support = require(__dirname + '/support');
const helpers = require(__dirname + '/support/helpers');
const gulp = require('gulp');
const optionsPath = Support.resolveSupportPath('config', 'options.js');
describe(Support.getTestDialectTeaser('options'), () => {
describe('--options-path', () => {
[
optionsPath,
require('path').relative(Support.resolveSupportPath('tmp'), optionsPath),
].forEach((path) => {
it(
'using options file instead of cli switches (' + path + ')',
(done) => {
gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
.pipe(helpers.runCli('init --options-path ' + path))
.pipe(helpers.listFiles())
.pipe(helpers.ensureContent('models'))
.pipe(helpers.teardown(done));
}
);
});
});
describe('.sequelizerc', () => {
it('uses .sequelizerc file', (done) => {
const configContent = `
var path = require('path');
module.exports = {
'config': path.resolve('config-new', 'database.json'),
'migrations-path': path.resolve('migrations-new')
};
`;
gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
.pipe(helpers.copyFile(optionsPath, '.sequelizerc'))
.pipe(helpers.overwriteFile(configContent, '.sequelizerc'))
.pipe(helpers.runCli('init'))
.pipe(helpers.listFiles())
.pipe(helpers.ensureContent('migrations-new'))
.pipe(helpers.ensureContent('config-new'))
.pipe(helpers.teardown(done));
});
it('prefers CLI arguments over .sequelizerc file', (done) => {
const configPath = Support.resolveSupportPath(
'tmp',
'config',
'config.js'
);
gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
.pipe(helpers.copyFile(optionsPath, '.sequelizerc'))
.pipe(helpers.runCli('init --config=' + configPath))
.pipe(helpers.listFiles())
.pipe(helpers.ensureContent('models'))
.pipe(helpers.teardown(done));
});
});
});