diff --git a/lib/workers/repository/onboarding/pr/index.spec.ts b/lib/workers/repository/onboarding/pr/index.spec.ts index 361a5fb7f0a601f2ef3fb07d3ed5e37eb090f974..d1b9ebcfd9ffa6f3607de2c57bbff5f75db84d34 100644 --- a/lib/workers/repository/onboarding/pr/index.spec.ts +++ b/lib/workers/repository/onboarding/pr/index.spec.ts @@ -5,6 +5,7 @@ import { partial, platform, } from '../../../../../test/util'; +import { logger } from '../../../../logger'; import { PackageFile } from '../../../../manager/common'; import { Pr } from '../../../../platform'; import { BranchConfig } from '../../../common'; @@ -85,5 +86,34 @@ describe('workers/repository/onboarding/pr', () => { await ensureOnboardingPr(config, packageFiles, branches); expect(platform.createPr).toHaveBeenCalledTimes(1); }); + it('dryrun of updates PR when modified', async () => { + config.dryRun = true; + config.baseBranch = 'some-branch'; + platform.getBranchPr.mockResolvedValueOnce( + partial<Pr>({ + title: 'Configure Renovate', + body: createPrBody, + isConflicted: true, + }) + ); + git.isBranchModified.mockResolvedValueOnce(true); + await ensureOnboardingPr(config, {}, branches); + expect(logger.info).toHaveBeenCalledWith( + 'DRY-RUN: Would check branch renovate/configure' + ); + expect(logger.info).toHaveBeenLastCalledWith( + 'DRY-RUN: Would update onboarding PR' + ); + }); + it('dryrun of creates PR', async () => { + config.dryRun = true; + await ensureOnboardingPr(config, packageFiles, branches); + expect(logger.info).toHaveBeenCalledWith( + 'DRY-RUN: Would check branch renovate/configure' + ); + expect(logger.info).toHaveBeenLastCalledWith( + 'DRY-RUN: Would create onboarding PR' + ); + }); }); }); diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index c5827181420ea21ab5b149eadf71cde2bae187f6..2ec8b74d47f8722d6363ebd0427281a912fb30fd 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -65,7 +65,9 @@ If you need any further assistance then you can also [request help here](${confi prBody = prBody.replace('{{PACKAGE FILES}}\n', ''); } let configDesc = ''; - if (await isBranchModified(config.onboardingBranch)) { + if (config.dryRun) { + logger.info(`DRY-RUN: Would check branch ${config.onboardingBranch}`); + } else if (await isBranchModified(config.onboardingBranch)) { configDesc = emojify( `### Configuration\n\n:abcd: Renovate has detected a custom config for this PR. Feel free to ask for [help](${config.productLinks.help}) if you have any doubts and would like it reviewed.\n\n` ); @@ -111,7 +113,6 @@ If you need any further assistance then you can also [request help here](${confi return; } // PR must need updating - // istanbul ignore if if (config.dryRun) { logger.info('DRY-RUN: Would update onboarding PR'); } else { @@ -127,7 +128,6 @@ If you need any further assistance then you can also [request help here](${confi logger.debug('Creating onboarding PR'); const labels: string[] = []; try { - // istanbul ignore if if (config.dryRun) { logger.info('DRY-RUN: Would create onboarding PR'); } else {