Skip to content
Snippets Groups Projects
Select Git revision
  • 764b2b7b67c17526e3b354374e759c9deb00365e
  • main default protected
  • renovate/main-renovatebot-osv-offline-1.x
  • fix/36927-maven-tags
  • renovate/main-redis-5.x
  • next
  • revert-31645-feat/rename-gradle-wrapper-validation-action
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • refactor/pin-new-value
  • 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
  • fix/32307-global-extends-repositories
  • 41.37.7
  • 41.37.6
  • 41.37.5
  • 41.37.4
  • 41.37.3
  • 41.37.2
  • 41.37.1
  • 41.37.0
  • 41.36.2
  • 41.36.1
  • 41.36.0
  • 41.35.2
  • 41.35.1
  • 41.35.0
  • 41.34.1
  • 41.34.0
  • 41.33.0
  • 41.32.3
  • 41.32.2
  • 41.32.1
41 results

extract-update.spec.ts

Blame
  • extract-update.spec.ts 2.14 KiB
    import hasha from 'hasha';
    import { mocked } from '../../../../test/util';
    import * as _repositoryCache from '../../../util/cache/repository';
    import * as _branchify from '../updates/branchify';
    import { extract, lookup, update } from './extract-update';
    
    jest.mock('./write');
    jest.mock('./sort');
    jest.mock('./fetch');
    jest.mock('../updates/branchify');
    jest.mock('../extract');
    jest.mock('../../../util/cache/repository');
    
    const branchify = mocked(_branchify);
    const repositoryCache = mocked(_repositoryCache);
    
    branchify.branchifyUpgrades.mockResolvedValueOnce({
      branches: [{ branchName: 'some-branch', upgrades: [] }],
      branchList: ['branchName'],
    });
    
    describe('workers/repository/process/extract-update', () => {
      describe('extract()', () => {
        it('runs with no baseBranches', async () => {
          const config = {
            repoIsOnboarded: true,
            suppressNotifications: ['deprecationWarningIssues'],
          };
          repositoryCache.getCache.mockReturnValueOnce({});
          const packageFiles = await extract(config);
          const res = await lookup(config, packageFiles);
          expect(res).toMatchSnapshot();
          await expect(update(config, res.branches)).resolves.not.toThrow();
        });
        it('runs with baseBranches', async () => {
          const config = {
            baseBranches: ['master', 'dev'],
            repoIsOnboarded: true,
            suppressNotifications: ['deprecationWarningIssues'],
          };
          repositoryCache.getCache.mockReturnValueOnce({});
          const packageFiles = await extract(config);
          expect(packageFiles).toMatchSnapshot();
        });
        it('uses repository cache', async () => {
          const packageFiles = [];
          const config = {
            repoIsOnboarded: true,
            suppressNotifications: ['deprecationWarningIssues'],
            baseBranch: 'master',
            baseBranchSha: 'abc123',
          };
          repositoryCache.getCache.mockReturnValueOnce({
            scan: {
              master: {
                sha: config.baseBranchSha,
                configHash: hasha(JSON.stringify(config)),
                packageFiles,
              },
            },
          });
          const res = await extract(config);
          expect(res).toEqual(packageFiles);
        });
      });
    });