diff --git a/lib/workers/repository/error-config.js b/lib/workers/repository/error-config.js index 9d23e1b26f45804053e463101f111526ca101074..62712a6a526ad34922e3650c99fca1529e8af644 100644 --- a/lib/workers/repository/error-config.js +++ b/lib/workers/repository/error-config.js @@ -23,7 +23,11 @@ async function raiseConfigWarningIssue(config, error) { logger.info('Updating onboarding PR with config error notice'); body = `## Action Required: Fix ${appName} Configuration\n\n${body}`; body += `\n\nOnce you have resolved this problem (in this onboarding branch), ${appName} will return to providing you with a preview of your repository's configuration.`; - await platform.updatePr(pr.number, onboardingPrTitle, body); + if (config.dryRun) { + logger.info('DRY-RUN: Would update PR #' + pr.number); + } else await platform.updatePr(pr.number, onboardingPrTitle, body); + } else if (config.dryRun) { + logger.info('DRY-RUN: Would ensure config error issue'); } else { const res = await platform.ensureIssue( `Action Required: Fix ${appName} Configuration`, diff --git a/test/workers/repository/error-config.spec.js b/test/workers/repository/error-config.spec.js index de1231e9193e302301dcbe9c1899d863badf76a2..f97b2b0dc44ca71ad7d77b568e9c751edb906794 100644 --- a/test/workers/repository/error-config.spec.js +++ b/test/workers/repository/error-config.spec.js @@ -18,6 +18,17 @@ describe('workers/repository/error-config', () => { const res = await raiseConfigWarningIssue(config, error); expect(res).toBeUndefined(); }); + it('creates issues (dryRun)', async () => { + const error = new Error('config-validation'); + error.configFile = 'package.json'; + error.validationMessage = 'some-message'; + platform.ensureIssue.mockReturnValue('created'); + const res = await raiseConfigWarningIssue( + { ...config, dryRun: true }, + error + ); + expect(res).toBeUndefined(); + }); it('handles onboarding', async () => { const error = new Error('config-validation'); error.configFile = 'package.json'; @@ -26,5 +37,16 @@ describe('workers/repository/error-config', () => { const res = await raiseConfigWarningIssue(config, error); expect(res).toBeUndefined(); }); + it('handles onboarding (dryRun)', async () => { + const error = new Error('config-validation'); + error.configFile = 'package.json'; + error.validationMessage = 'some-message'; + platform.getBranchPr.mockReturnValueOnce({ number: 1, state: 'open' }); + const res = await raiseConfigWarningIssue( + { ...config, dryRun: true }, + error + ); + expect(res).toBeUndefined(); + }); }); });