Skip to content
Snippets Groups Projects
Select Git revision
  • 097fe71742cbcba7f0f53ceac2ebf78986dc4d99
  • master default protected
  • enable_fossa
  • release-0.7
  • v0.16.2 protected
  • v0.16.1 protected
  • v0.16.0 protected
  • v0.15.3 protected
  • v0.15.2 protected
  • v0.15.1 protected
  • v0.15.0 protected
  • v0.15.0-rc2 protected
  • v0.15.0-rc1 protected
  • v0.14.2 protected
  • v0.14.1 protected
  • v0.14.0 protected
  • v0.14.0-rc4 protected
  • v0.14.0-rc3 protected
  • v0.14.0-rc2 protected
  • v0.14.0-rc1 protected
  • v0.13.4 protected
  • v0.13.3 protected
  • v0.13.2 protected
  • v0.13.1 protected
24 results

package-controller

Blame
  • index.spec.js 8.39 KiB
    const branchWorker = require('../../../lib/workers/branch');
    const defaultConfig = require('../../../lib/config/defaults').getConfig();
    
    const schedule = require('../../../lib/workers/branch/schedule');
    const checkExisting = require('../../../lib/workers/branch/check-existing');
    const parent = require('../../../lib/workers/branch/parent');
    const manager = require('../../../lib/manager');
    const lockFiles = require('../../../lib/workers/branch/lock-files');
    const commit = require('../../../lib/workers/branch/commit');
    const statusChecks = require('../../../lib/workers/branch/status-checks');
    const automerge = require('../../../lib/workers/branch/automerge');
    const prWorker = require('../../../lib/workers/pr');
    
    jest.mock('../../../lib/manager');
    jest.mock('../../../lib/workers/branch/schedule');
    jest.mock('../../../lib/workers/branch/check-existing');
    jest.mock('../../../lib/workers/branch/parent');
    jest.mock('../../../lib/workers/branch/lock-files');
    jest.mock('../../../lib/workers/branch/commit');
    jest.mock('../../../lib/workers/branch/status-checks');
    jest.mock('../../../lib/workers/branch/automerge');
    jest.mock('../../../lib/workers/pr');
    
    const logger = require('../../_fixtures/logger');
    
    describe('workers/branch', () => {
      describe('processBranch', () => {
        let config;
        beforeEach(() => {
          prWorker.ensurePr = jest.fn();
          prWorker.checkAutoMerge = jest.fn();
          config = {
            ...defaultConfig,
            errors: [],
            warnings: [],
            logger,
            upgrades: [{ depName: 'some-dep-name' }],
          };
          schedule.isScheduledNow.mockReturnValue(true);
        });
        afterEach(() => {
          platform.ensureComment.mockClear();
          platform.ensureCommentRemoval.mockClear();
        });
        it('skips branch if not scheduled and branch does not exist', async () => {
          schedule.isScheduledNow.mockReturnValueOnce(false);
          await branchWorker.processBranch(config);
          expect(checkExisting.prAlreadyExisted.mock.calls).toHaveLength(0);
        });
        it('skips branch if not scheduled and not updating out of schedule', async () => {
          schedule.isScheduledNow.mockReturnValueOnce(false);
          config.updateNotScheduled = false;
          platform.branchExists.mockReturnValueOnce(true);
          await branchWorker.processBranch(config);
          expect(checkExisting.prAlreadyExisted.mock.calls).toHaveLength(0);
        });
        it('skips branch if closed major PR found', async () => {
          schedule.isScheduledNow.mockReturnValueOnce(false);
          platform.branchExists.mockReturnValueOnce(true);
          config.isMajor = true;
          checkExisting.prAlreadyExisted.mockReturnValueOnce({ number: 13 });
          await branchWorker.processBranch(config);
          expect(parent.getParentBranch.mock.calls.length).toBe(0);
          expect(config.logger.error.mock.calls).toHaveLength(0);
        });
        it('skips branch if closed digest PR found', async () => {
          schedule.isScheduledNow.mockReturnValueOnce(false);
          platform.branchExists.mockReturnValueOnce(true);
          config.isDigest = true;
          checkExisting.prAlreadyExisted.mockReturnValueOnce({ number: 13 });