From 430c05528cb6e288411f4f751439b5a093497206 Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Fri, 12 Jul 2019 07:41:34 +0200 Subject: [PATCH] fix(worker): no config error on dryRun (#4054) --- lib/workers/repository/error-config.js | 6 +++++- test/workers/repository/error-config.spec.js | 22 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/workers/repository/error-config.js b/lib/workers/repository/error-config.js index 9d23e1b26f..62712a6a52 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 de1231e919..f97b2b0dc4 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(); + }); }); }); -- GitLab