2017-02-09 04:30:00 +00:00
|
|
|
const env = require('../../lib/config/env.js');
|
2017-01-20 13:03:18 +00:00
|
|
|
|
|
|
|
describe('config/env', () => {
|
|
|
|
describe('.getConfig(env)', () => {
|
|
|
|
it('returns empty env', () => {
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig({}).should.eql({});
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports boolean true', () => {
|
|
|
|
const envParam = { RENOVATE_RECREATE_CLOSED: 'true' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ recreateClosed: true });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports boolean false', () => {
|
|
|
|
const envParam = { RENOVATE_RECREATE_CLOSED: 'false' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ recreateClosed: false });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports boolean nonsense as false', () => {
|
|
|
|
const envParam = { RENOVATE_RECREATE_CLOSED: 'foo' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ recreateClosed: false });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
delete process.env.RENOVATE_RECREATE_CLOSED;
|
|
|
|
it('supports list single', () => {
|
|
|
|
const envParam = { RENOVATE_LABELS: 'a' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ labels: ['a'] });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports list multiple', () => {
|
|
|
|
const envParam = { RENOVATE_LABELS: 'a,b,c' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ labels: ['a', 'b', 'c'] });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
it('supports string', () => {
|
2017-01-31 17:16:33 +00:00
|
|
|
const envParam = { RENOVATE_TOKEN: 'a' };
|
2018-07-02 11:18:37 +00:00
|
|
|
env.getConfig(envParam).should.eql({ token: 'a' });
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
2017-07-24 18:56:15 +00:00
|
|
|
it('supports json', () => {
|
|
|
|
const envParam = { RENOVATE_LOCK_FILE_MAINTENANCE: '{}' };
|
2018-07-02 11:18:37 +00:00
|
|
|
expect(env.getConfig(envParam)).toEqual({ lockFileMaintenance: {} });
|
2017-07-24 18:56:15 +00:00
|
|
|
});
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
|
|
|
describe('.getEnvName(definition)', () => {
|
2017-01-31 11:19:06 +00:00
|
|
|
it('returns empty', () => {
|
|
|
|
const option = {
|
|
|
|
name: 'foo',
|
|
|
|
env: false,
|
|
|
|
};
|
|
|
|
env.getEnvName(option).should.eql('');
|
|
|
|
});
|
2017-01-20 13:03:18 +00:00
|
|
|
it('returns existing env', () => {
|
|
|
|
const option = {
|
|
|
|
name: 'foo',
|
|
|
|
env: 'FOO',
|
|
|
|
};
|
|
|
|
env.getEnvName(option).should.eql('FOO');
|
|
|
|
});
|
|
|
|
it('generates RENOVATE_ env', () => {
|
|
|
|
const option = {
|
|
|
|
name: 'oneTwoThree',
|
|
|
|
};
|
|
|
|
env.getEnvName(option).should.eql('RENOVATE_ONE_TWO_THREE');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|