<commit_before>const argv = require('./config/_fixtures/argv');
const defaultConfig = require('../../lib/config/defaults').getConfig();
const npm = require('../../lib/datasource/npm');
const presetDefaults = require('./npm/_fixtures/renovate-config-default');

npm.getPkgReleases = jest.fn(() => ({
  'renovate-config':
    presetDefaults.versions[presetDefaults['dist-tags'].latest][
      'renovate-config'
    ],
}));

describe('config/index', () => {
  describe('.parseConfigs(env, defaultArgv)', () => {
    let configParser;
    let defaultArgv;
    beforeEach(() => {
      jest.resetModules();
      configParser = require('../../lib/config/index.js');
      defaultArgv = argv();
      jest.mock('delay');
      require('delay').mockImplementation(() => Promise.resolve());
    });
    it('throws for invalid platform', async () => {
      const env = {};
      defaultArgv.push('--platform=foo');
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe('Unsupported platform: foo.');
    });
    it('throws for no GitHub token', async () => {
      const env = {};
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform https://api.github.com/ (github)'
      );
    });
    it('throws for no GitLab token', async () => {
      const env = { RENOVATE_PLATFORM: 'gitlab' };
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform https://gitlab.com/api/v4/ (gitlab)'
      );
    });
    it('throws for no Azure DevOps token', async () => {
      const env = { RENOVATE_PLATFORM: 'azure' };
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform undefined (azure)'
      );
    });
    it('supports token in env', async () => {
      const env = { RENOVATE_TOKEN: 'abc' };
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports token in CLI options', async () => {
      defaultArgv = defaultArgv.concat(['--token=abc', '--pr-footer=custom']);
      const env = {};
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports forceCli', async () => {
      defaultArgv = defaultArgv.concat(['--force-cli=true']);
      const env = { RENOVATE_TOKEN: 'abc' };
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports Bitbucket username/passwod', async () => {
      defaultArgv = defaultArgv.concat([
        '--platform=bitbucket',
        '--username=user',
        '--password=<PASSWORD>',
      ]);
      const env = {};<commit_msg>tests: ignore config file<commit_after>const argv = require('./config/_fixtures/argv');
const defaultConfig = require('../../lib/config/defaults').getConfig();
const npm = require('../../lib/datasource/npm');
const presetDefaults = require('./npm/_fixtures/renovate-config-default');

npm.getPkgReleases = jest.fn(() => ({
  'renovate-config':
    presetDefaults.versions[presetDefaults['dist-tags'].latest][
      'renovate-config'
    ],
}));

describe('config/index', () => {
  describe('.parseConfigs(env, defaultArgv)', () => {
    let configParser;
    let defaultArgv;
    beforeEach(() => {
      jest.resetModules();
      configParser = require('../../lib/config/index.js');
      defaultArgv = argv();
      jest.mock('delay');
      require('delay').mockImplementation(() => Promise.resolve());
    });
    it('throws for invalid platform', async () => {
      const env = {};
      defaultArgv.push('--platform=foo');
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe('Unsupported platform: foo.');
    });
    it('throws for no GitHub token', async () => {
      const env = { RENOVATE_CONFIG_FILE: '/tmp/does-not-exist' };
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform https://api.github.com/ (github)'
      );
    });
    it('throws for no GitLab token', async () => {
      const env = {
        RENOVATE_CONFIG_FILE: '/tmp/does-not-exist',
        RENOVATE_PLATFORM: 'gitlab',
      };
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform https://gitlab.com/api/v4/ (gitlab)'
      );
    });
    it('throws for no Azure DevOps token', async () => {
      const env = {
        RENOVATE_CONFIG_FILE: '/tmp/does-not-exist',
        RENOVATE_PLATFORM: 'azure',
      };
      let err;
      try {
        await configParser.parseConfigs(env, defaultArgv);
      } catch (e) {
        err = e;
      }
      expect(err.message).toBe(
        'No authentication found for platform undefined (azure)'
      );
    });
    it('supports token in env', async () => {
      const env = { RENOVATE_TOKEN: 'abc' };
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports token in CLI options', async () => {
      defaultArgv = defaultArgv.concat(['--token=abc', '--pr-footer=custom']);
      const env = {};
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports forceCli', async () => {
      defaultArgv = defaultArgv.concat(['--force-cli=true']);
      const env = { RENOVATE_TOKEN: 'abc' };
      await configParser.parseConfigs(env, defaultArgv);
    });
    it('supports Bitbucket username/passwod', async () => {
      defaultArgv = defaultArgv.concat([
        '--platform=bitbucket',
        '--username=user',
        '--password=<PASSWORD>',
      ]);
      const env = {};
{'fraction_non_alphanumeric': 0.1668560298652816, 'fraction_numerical': 0.00032462262619704593, 'mean_word_length': 2.475465313028765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4195763', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1885, 'n_words': 381}