2017-01-31 11:19:06 +00:00
|
|
|
const configParser = require('../../dist/config/index.js');
|
2017-01-20 13:03:18 +00:00
|
|
|
const defaultArgv = require('../_fixtures/config/argv');
|
|
|
|
const should = require('chai').should();
|
|
|
|
|
|
|
|
describe('config/index', () => {
|
|
|
|
describe('.parseConfigs(env, defaultArgv)', () => {
|
|
|
|
it('throws for no token', () => {
|
|
|
|
const env = {};
|
2017-01-31 17:16:33 +00:00
|
|
|
configParser.parseConfigs.bind(configParser, env, defaultArgv).should.throw('At least one repository must be configured');
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports token in env', () => {
|
|
|
|
const env = { GITHUB_TOKEN: 'abc' };
|
|
|
|
configParser.parseConfigs.bind(configParser, env, defaultArgv).should.throw('At least one repository must be configured');
|
|
|
|
});
|
|
|
|
it('supports token in CLI options', () => {
|
|
|
|
const env = {};
|
|
|
|
const argv = defaultArgv.concat(['--token=abc']);
|
|
|
|
configParser.parseConfigs.bind(configParser, env, argv).should.throw('At least one repository must be configured');
|
|
|
|
});
|
|
|
|
it('supports repositories in CLI', () => {
|
|
|
|
const env = {};
|
|
|
|
const argv = defaultArgv.concat(['--token=abc', 'foo']);
|
|
|
|
configParser.parseConfigs(env, argv);
|
2017-01-22 13:40:14 +00:00
|
|
|
const repos = configParser.getRepositories();
|
|
|
|
should.exist(repos);
|
|
|
|
repos.should.have.length(1);
|
|
|
|
repos[0].repository.should.eql('foo');
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('gets cascaded config', () => {
|
|
|
|
const env = { RENOVATE_CONFIG_FILE: 'test/_fixtures/config/file.js' };
|
|
|
|
configParser.parseConfigs(env, defaultArgv);
|
2017-01-22 13:40:14 +00:00
|
|
|
const repo = configParser.getRepositories().pop();
|
2017-01-20 13:03:18 +00:00
|
|
|
should.exist(repo);
|
|
|
|
const cascadedConfig = configParser.getCascadedConfig(repo, null);
|
|
|
|
should.exist(cascadedConfig.token);
|
|
|
|
should.exist(cascadedConfig.recreateClosed);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|