renovate/test/config/index.js

40 lines
1.6 KiB
JavaScript
Raw Normal View History

const configParser = require('../../dist/config/index.js');
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 = {};
configParser.parseConfigs.bind(configParser, env, defaultArgv).should.throw('A GitHub token must be configured');
});
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');
});
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();
should.exist(repo);
const cascadedConfig = configParser.getCascadedConfig(repo, null);
should.exist(cascadedConfig.token);
should.exist(cascadedConfig.recreateClosed);
});
});
});