-
-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathdb-info.test.js
74 lines (64 loc) · 2.23 KB
/
db-info.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
68
69
70
71
72
73
74
const expect = require('expect.js');
const Support = require(__dirname + '/../support');
const helpers = require(__dirname + '/../support/helpers');
const gulp = require('gulp');
const _ = require('lodash');
['db:info'].forEach((flag) => {
describe(Support.getTestDialectTeaser(flag), function () {
this.timeout(5000);
if (Support.dialectIsPostgres() || Support.dialectIsMySQL()) {
console.log("we're testing");
const combineFlags = function (flags) {
let result = flag;
_.forEach(flags || {}, (value, key) => {
result = result + ' --' + key;
});
return result;
};
const prepare = function (options, callback) {
options = _.assign(
{
flags: {},
cli: { pipeStdout: true },
},
options || {}
);
console.log('fl', combineFlags(options.flags));
const configPath = 'config/config.json';
const config = _.assign(
{ password: 'secret_password' },
helpers.getTestConfig(),
options.config
);
const configContent = JSON.stringify(config);
gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
.pipe(helpers.runCli('init'))
.pipe(helpers.runCli('db:create'))
.pipe(
// helpers.overwriteFile(helpers.getTestConfig(), 'config/config.json')
helpers.overwriteFile(configContent, configPath)
)
.pipe(helpers.runCli(flag, { pipeStdout: true }))
// .pipe(helpers.runCli(combineFlags(options.flags), options.cli))
.pipe(helpers.teardown(callback));
};
describe('show-password', function () {
it('hides the password', function (done) {
prepare({}, (err, stdout) => {
expect(stdout).to.contain('password: ***');
done();
});
});
it.only('reveals the password', function (done) {
prepare({ flags: { 'show-password': true } }, done);
// prepare({ flags: { showPassword: true } }, (err, stdout) => {
// expect(stdout).not.to.contain('password: ***');
// done();
// });
});
});
}
});
});