Skip to content
Snippets Groups Projects
Select Git revision
  • c73b92f188b57e76692509e8f56dbe0ea0efe008
  • dependabot/npm_and_yarn/eslint-plugin-prettier-5.5.1
  • dependabot/npm_and_yarn/chai-5.2.1
  • dependabot/npm_and_yarn/smol-toml-1.4.1
  • dependabot/npm_and_yarn/sentry/node-9.38.0
  • dependabot/npm_and_yarn/webextension-store-meta-1.2.7
  • dependabot/npm_and_yarn/eslint-9.30.1
  • dependabot/npm_and_yarn/cypress-14.5.1
  • dependabot/npm_and_yarn/simple-icons-15.5.0
  • dependabot/npm_and_yarn/eslint-plugin-import-2.32.0
  • dependabot/npm_and_yarn/eslint-plugin-jsdoc-51.3.4
  • dependabot/npm_and_yarn/prettier-3.6.2
  • dependabot/npm_and_yarn/is-svg-6.1.0
  • dependabot/npm_and_yarn/query-string-9.2.2
  • dependabot/npm_and_yarn/mocha-11.7.1
  • dependabot/npm_and_yarn/globals-16.3.0
  • dependabot/npm_and_yarn/neostandard-0.12.2
  • dependabot/npm_and_yarn/concurrently-9.2.0
  • dependabot/npm_and_yarn/pg-8.16.3
  • dependabot/npm_and_yarn/typescript-eslint/parser-8.36.0
  • gh-pages
  • server-2025-07-01
  • 5.0.2
  • 5.0.1
  • 5.0.0
  • server-2025-06-01
  • server-2025-05-01
  • server-2025-04-03
  • server-2025-03-02
  • server-2025-03-01
  • server-2025-02-02
  • server-2025-01-01
  • server-2024-12-01
  • server-2024-11-02
  • 4.1.0
  • server-2024-09-25
  • server-2024-09-02
  • server-2024-08-01
  • server-2024-07-01
  • 4.0.0
  • server-2024-06-01
41 results

server.js

Blame
  • limits.spec.ts 2.06 KiB
    import moment from 'moment';
    import * as limits from './limits';
    import { platform, getConfig, RenovateConfig } from '../../../../test/util';
    import { BranchConfig } from '../../common';
    
    let config: RenovateConfig;
    beforeEach(() => {
      jest.resetAllMocks();
      config = getConfig();
    });
    
    describe('workers/repository/process/limits', () => {
      describe('getPrHourlyRemaining()', () => {
        it('calculates hourly limit remaining', async () => {
          config.prHourlyLimit = 2;
          platform.getPrList.mockResolvedValueOnce([
            {
              created_at: moment().format(),
              branchName: null,
              title: null,
              state: null,
            },
          ]);
          const res = await limits.getPrHourlyRemaining(config);
          expect(res).toEqual(1);
        });
        it('returns 99 if errored', async () => {
          config.prHourlyLimit = 2;
          platform.getPrList.mockResolvedValueOnce([null]);
          const res = await limits.getPrHourlyRemaining(config);
          expect(res).toEqual(99);
        });
      });
      describe('getConcurrentPrsRemaining()', () => {
        it('calculates concurrent limit remaining', async () => {
          config.prConcurrentLimit = 20;
          platform.branchExists.mockResolvedValueOnce(true);
          const branches: BranchConfig[] = [
            { branchName: 'test', upgrades: [] },
            { branchName: undefined, upgrades: [] },
          ];
          const res = await limits.getConcurrentPrsRemaining(config, branches);
          expect(res).toEqual(19);
        });
        it('returns 99 if no concurrent limit', async () => {
          const res = await limits.getConcurrentPrsRemaining(config, []);
          expect(res).toEqual(99);
        });
      });
    
      describe('getPrsRemaining()', () => {
        it('returns hourly limit', async () => {
          config.prHourlyLimit = 5;
          platform.getPrList.mockResolvedValueOnce([]);
          const res = await limits.getPrsRemaining(config, []);
          expect(res).toEqual(5);
        });
        it('returns concurrent limit', async () => {
          config.prConcurrentLimit = 5;
          const res = await limits.getPrsRemaining(config, []);
          expect(res).toEqual(5);
        });
      });
    });