Skip to content
Snippets Groups Projects
Select Git revision
  • 456245aabe465529d6623dafd8aa32ed152f5365
  • main default protected
  • renovate/main-ghcr.io-renovatebot-base-image-11.x
  • chore/maintainers-rarkins
  • refactor/pin-new-value
  • fix/user-agent
  • feat/37517-base64-private-key
  • next
  • feat/gnupg
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • 41.84.0
  • 41.83.2
  • 41.83.1
  • 41.83.0
  • 41.82.10
  • 41.82.9
  • 41.82.8
  • 41.82.7
  • 41.82.6
  • 41.82.5
  • 41.82.4
  • 41.82.3
  • 41.82.2
  • 41.82.1
  • 41.82.0
  • 41.81.6
  • 41.81.5
  • 41.81.4
  • 41.81.3
  • 41.81.2
41 results

master-issue.spec.ts

Blame
  • master-issue.spec.ts 15.10 KiB
    import fs from 'fs';
    import { mock } from 'jest-mock-extended';
    import { RenovateConfig, getConfig, platform } from '../../../test/util';
    import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
    import { PR_STATE_NOT_OPEN } from '../../constants/pull-requests';
    import { Platform, Pr } from '../../platform';
    import { BranchConfig, BranchUpgradeConfig } from '../common';
    import * as dependencyDashboard from './master-issue';
    
    type PrUpgrade = BranchUpgradeConfig;
    
    let config: RenovateConfig;
    beforeEach(() => {
      jest.resetAllMocks();
      config = getConfig();
      config.platform = PLATFORM_TYPE_GITHUB;
      config.errors = [];
      config.warnings = [];
    });
    
    async function dryRun(
      branches: BranchConfig[],
      // eslint-disable-next-line no-shadow
      platform: jest.Mocked<Platform>,
      ensureIssueClosingCalls = 0,
      ensureIssueCalls = 0,
      getBranchPrCalls = 0,
      findPrCalls = 0
    ) {
      jest.resetAllMocks();
      config.dryRun = true;
      await dependencyDashboard.ensureMasterIssue(config, branches);
      expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
        ensureIssueClosingCalls
      );
      expect(platform.ensureIssue).toHaveBeenCalledTimes(ensureIssueCalls);
      expect(platform.getBranchPr).toHaveBeenCalledTimes(getBranchPrCalls);
      expect(platform.findPr).toHaveBeenCalledTimes(findPrCalls);
    }
    
    describe('workers/repository/master-issue', () => {
      describe('ensureMasterIssue()', () => {
        it('do nothing if masterissue is disable', async () => {
          const branches: BranchConfig[] = [];
          await dependencyDashboard.ensureMasterIssue(config, branches);
          expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
          expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
          expect(platform.getBranchPr).toHaveBeenCalledTimes(0);
          expect(platform.findPr).toHaveBeenCalledTimes(0);
    
          // same with dry run
          await dryRun(branches, platform);
        });
    
        it('do nothing if it has no masterissueapproval branches', async () => {
          const branches = [
            {
              ...mock<BranchConfig>(),
              prTitle: 'pr1',
            },
            {
              ...mock<BranchConfig>(),
              prTitle: 'pr2',
              dependencyDashboardApproval: false,
            },
          ];
          await dependencyDashboard.ensureMasterIssue(config, branches);
          expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
          expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
          expect(platform.getBranchPr).toHaveBeenCalledTimes(0);