From c608ac2e46dd71f3d6ceab1db7eebc9c34e3b323 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Sun, 2 Jul 2017 06:44:49 +0200
Subject: [PATCH] refactor: rename branchWorker.updateBranch ->
 processBranchUpgrades

---
 lib/workers/branch/index.js             |  4 ++--
 lib/workers/repository/index.js         |  2 +-
 test/workers/branch/index.spec.js       | 16 ++++++++--------
 test/workers/package-file/index.spec.js |  1 -
 test/workers/repository/index.spec.js   |  6 +++---
 5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/lib/workers/branch/index.js b/lib/workers/branch/index.js
index 26266f1806..439146ac2b 100644
--- a/lib/workers/branch/index.js
+++ b/lib/workers/branch/index.js
@@ -8,7 +8,7 @@ let logger = require('../../logger');
 module.exports = {
   getParentBranch,
   ensureBranch,
-  updateBranch,
+  processBranchUpgrades,
   removeStandaloneBranches,
 };
 
@@ -194,7 +194,7 @@ async function ensureBranch(upgrades) {
   return true;
 }
 
-async function updateBranch(upgrades) {
+async function processBranchUpgrades(upgrades) {
   await removeStandaloneBranches(upgrades);
   const upgrade0 = upgrades[0];
   // Delete the semanticPrefix for this branch if feature is not enabled
diff --git a/lib/workers/repository/index.js b/lib/workers/repository/index.js
index dc38e365d5..736c74d148 100644
--- a/lib/workers/repository/index.js
+++ b/lib/workers/repository/index.js
@@ -52,7 +52,7 @@ async function renovateRepository(packageFileConfig) {
     );
     if (config.repoIsOnboarded) {
       for (const branchName of Object.keys(branchUpgrades)) {
-        await branchWorker.updateBranch(branchUpgrades[branchName]);
+        await branchWorker.processBranchUpgrades(branchUpgrades[branchName]);
       }
     } else {
       await onboarding.ensurePr(config, branchUpgrades);
diff --git a/test/workers/branch/index.spec.js b/test/workers/branch/index.spec.js
index 00151d58bc..dd972efaed 100644
--- a/test/workers/branch/index.spec.js
+++ b/test/workers/branch/index.spec.js
@@ -320,7 +320,7 @@ describe('workers/branch', () => {
       expect(config.api.commitFilesToBranch.mock.calls.length).toBe(0);
     });
   });
-  describe('updateBranch(upgrades)', () => {
+  describe('processBranchUpgrades(upgrades)', () => {
     let config;
     beforeEach(() => {
       config = Object.assign({}, defaultConfig);
@@ -333,41 +333,41 @@ describe('workers/branch', () => {
     });
     it('returns immediately if closed PR found', async () => {
       config.api.checkForClosedPr.mockReturnValue(true);
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(0);
     });
     it('does not return immediately if recreateClosed true', async () => {
       config.api.checkForClosedPr.mockReturnValue(true);
       config.recreateClosed = true;
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(1);
     });
     it('pins', async () => {
       config.upgradeType = 'pin';
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(1);
     });
     it('majors', async () => {
       config.upgradeType = 'major';
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(1);
     });
     it('minors', async () => {
       config.upgradeType = 'minor';
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(1);
     });
     it('handles semantic commits', async () => {
       config.upgradeType = 'minor';
       config.semanticCommits = true;
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(1);
     });
     it('handles errors', async () => {
       config.api.checkForClosedPr = jest.fn(() => {
         throw new Error('oops');
       });
-      await branchWorker.updateBranch([config]);
+      await branchWorker.processBranchUpgrades([config]);
       expect(branchWorker.ensureBranch.mock.calls.length).toBe(0);
     });
   });
diff --git a/test/workers/package-file/index.spec.js b/test/workers/package-file/index.spec.js
index 238785d6ff..1b24470bbd 100644
--- a/test/workers/package-file/index.spec.js
+++ b/test/workers/package-file/index.spec.js
@@ -20,7 +20,6 @@ describe('packageFileWorker', () => {
         depTypes: ['dependencies', 'devDependencies'],
         logger,
       });
-      packageFileWorker.updateBranch = jest.fn();
     });
     it('handles null', async () => {
       const allUpgrades = await packageFileWorker.findUpgrades(config);
diff --git a/test/workers/repository/index.spec.js b/test/workers/repository/index.spec.js
index 4b2abab7cd..ab6c20dc27 100644
--- a/test/workers/repository/index.spec.js
+++ b/test/workers/repository/index.spec.js
@@ -19,7 +19,7 @@ describe('workers/repository', () => {
       onboarding.ensurePr = jest.fn();
       upgrades.determineRepoUpgrades = jest.fn(() => []);
       upgrades.branchifyUpgrades = jest.fn(() => ({}));
-      branchWorker.updateBranch = jest.fn();
+      branchWorker.processBranchUpgrades = jest.fn();
       config = {
         api: {
           getFileJson: jest.fn(),
@@ -54,7 +54,7 @@ describe('workers/repository', () => {
       );
       await repositoryWorker.renovateRepository(config);
       expect(onboarding.getOnboardingStatus.mock.calls.length).toBe(1);
-      expect(branchWorker.updateBranch.mock.calls.length).toBe(0);
+      expect(branchWorker.processBranchUpgrades.mock.calls.length).toBe(0);
       expect(onboarding.ensurePr.mock.calls.length).toBe(1);
       expect(config.logger.error.mock.calls.length).toBe(0);
     });
@@ -68,7 +68,7 @@ describe('workers/repository', () => {
         baz: {},
       });
       await repositoryWorker.renovateRepository(config);
-      expect(branchWorker.updateBranch.mock.calls.length).toBe(3);
+      expect(branchWorker.processBranchUpgrades.mock.calls.length).toBe(3);
       expect(config.logger.error.mock.calls.length).toBe(0);
     });
     it('swallows errors', async () => {
-- 
GitLab