|
1 | 1 | import upath from 'upath'; |
| 2 | +import { getConfigFileNames } from '../../../../config/app-strings'; |
2 | 3 | import * as _decrypt from '../../../../config/decrypt'; |
3 | 4 | import { CONFIG_PRESETS_INVALID } from '../../../../constants/error-messages'; |
4 | 5 | import { getCustomEnv } from '../../../../util/env'; |
@@ -351,5 +352,45 @@ describe('workers/global/config/parse/index', () => { |
351 | 352 | ); |
352 | 353 | expect(parsedConfig.extends).toMatchObject([':pinDigests']); |
353 | 354 | }); |
| 355 | + |
| 356 | + it('appends files from configFileNames to config filenames list', async () => { |
| 357 | + // Capture the length we add our custom filenames. |
| 358 | + const lengthBefore = getConfigFileNames().length; |
| 359 | + fileConfigParser.getConfig.mockResolvedValue({ |
| 360 | + configFileNames: ['myrenovate.json', '.github/myrenovate.json'], |
| 361 | + }); |
| 362 | + const parsedConfig = await configParser.parseConfigs( |
| 363 | + defaultEnv, |
| 364 | + defaultArgv, |
| 365 | + ); |
| 366 | + expect(parsedConfig.configFileNames).toBeUndefined(); |
| 367 | + expect(getConfigFileNames()[0]).toBe('myrenovate.json'); |
| 368 | + expect(getConfigFileNames()[1]).toBe('.github/myrenovate.json'); |
| 369 | + // Ensure we added exactly two filenames. |
| 370 | + expect(getConfigFileNames().length).toBe(lengthBefore + 2); |
| 371 | + }); |
| 372 | + |
| 373 | + it('supports setting configFileNames through cli', async () => { |
| 374 | + fileConfigParser.getConfig.mockResolvedValue({}); |
| 375 | + defaultArgv = defaultArgv.concat([ |
| 376 | + '--config-file-names=myrenovate.json,.github/myrenovate.json', |
| 377 | + ]); |
| 378 | + const parsed = await configParser.parseConfigs(defaultEnv, defaultArgv); |
| 379 | + expect(parsed.configFileNames).toBeUndefined(); |
| 380 | + expect(getConfigFileNames()[0]).toBe('myrenovate.json'); |
| 381 | + expect(getConfigFileNames()[1]).toBe('.github/myrenovate.json'); |
| 382 | + }); |
| 383 | + |
| 384 | + it('supports setting configFileNames through env', async () => { |
| 385 | + fileConfigParser.getConfig.mockResolvedValue({}); |
| 386 | + const env: NodeJS.ProcessEnv = { |
| 387 | + RENOVATE_CONFIG_FILE_NAMES: |
| 388 | + '["myrenovate.json", ".github/myrenovate.json"]', |
| 389 | + }; |
| 390 | + const parsedConfig = await configParser.parseConfigs(env, defaultArgv); |
| 391 | + expect(parsedConfig.configFileNames).toBeUndefined(); |
| 392 | + expect(getConfigFileNames()[0]).toBe('myrenovate.json'); |
| 393 | + expect(getConfigFileNames()[1]).toBe('.github/myrenovate.json'); |
| 394 | + }); |
354 | 395 | }); |
355 | 396 | }); |
0 commit comments