Skip to content
Snippets Groups Projects
Select Git revision
  • 59ea152087c22ef657b5321ede9235a652e5ee3f
  • main default protected
  • renovate/main-zod-3.x
  • renovate/main-ghcr.io-renovatebot-base-image-10.x
  • renovate/main-ghcr.io-containerbase-devcontainer-13.x
  • next
  • revert-31645-feat/rename-gradle-wrapper-validation-action
  • renovate/main-redis-5.x
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • fix/36615-branch-reuse-bug
  • 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
  • 41.28.2
  • 41.28.1
  • 41.28.0
  • 41.27.1
  • 41.27.0
  • 41.26.2
  • 41.26.1
  • 41.26.0
  • 41.25.1
  • 41.25.0
  • 41.24.0
  • 41.23.5
  • 41.23.4
  • 41.23.3
  • 41.23.2
  • 41.23.1
  • 41.23.0
  • 41.22.0
  • 41.21.4
  • 41.21.3
41 results

get-updated.spec.ts

Blame
  • error.spec.ts 3.46 KiB
    import { RenovateConfig, partial } from '../../../test/util';
    import {
      CONFIG_SECRETS_EXPOSED,
      CONFIG_VALIDATION,
      EXTERNAL_HOST_ERROR,
      MANAGER_LOCKFILE_ERROR,
      MISSING_API_CREDENTIALS,
      NO_VULNERABILITY_ALERTS,
      PLATFORM_AUTHENTICATION_ERROR,
      PLATFORM_BAD_CREDENTIALS,
      PLATFORM_INTEGRATION_UNAUTHORIZED,
      PLATFORM_RATE_LIMIT_EXCEEDED,
      REPOSITORY_ACCESS_FORBIDDEN,
      REPOSITORY_ARCHIVED,
      REPOSITORY_BLOCKED,
      REPOSITORY_CANNOT_FORK,
      REPOSITORY_CHANGED,
      REPOSITORY_DISABLED,
      REPOSITORY_EMPTY,
      REPOSITORY_FORKED,
      REPOSITORY_MIRRORED,
      REPOSITORY_NOT_FOUND,
      REPOSITORY_NO_PACKAGE_FILES,
      REPOSITORY_RENAMED,
      REPOSITORY_UNINITIATED,
      SYSTEM_INSUFFICIENT_DISK_SPACE,
      SYSTEM_INSUFFICIENT_MEMORY,
      TEMPORARY_ERROR,
      UNKNOWN_ERROR,
    } from '../../constants/error-messages';
    import { ExternalHostError } from '../../types/errors/external-host-error';
    import handleError from './error';
    
    jest.mock('./error-config');
    
    let config: RenovateConfig;
    
    beforeEach(() => {
      jest.resetAllMocks();
      config = partial<RenovateConfig>({ branchList: [] });
    });
    
    describe('workers/repository/error', () => {
      describe('handleError()', () => {
        const errors = [
          REPOSITORY_UNINITIATED,
          REPOSITORY_EMPTY,
          REPOSITORY_DISABLED,
          REPOSITORY_CHANGED,
          REPOSITORY_FORKED,
          REPOSITORY_NO_PACKAGE_FILES,
          CONFIG_SECRETS_EXPOSED,
          CONFIG_VALIDATION,
          REPOSITORY_ARCHIVED,
          REPOSITORY_MIRRORED,
          REPOSITORY_RENAMED,
          REPOSITORY_BLOCKED,
          REPOSITORY_NOT_FOUND,
          REPOSITORY_ACCESS_FORBIDDEN,
          PLATFORM_BAD_CREDENTIALS,
          PLATFORM_RATE_LIMIT_EXCEEDED,
          MANAGER_LOCKFILE_ERROR,
          MISSING_API_CREDENTIALS,
          SYSTEM_INSUFFICIENT_DISK_SPACE,
          SYSTEM_INSUFFICIENT_MEMORY,
          NO_VULNERABILITY_ALERTS,
          REPOSITORY_CANNOT_FORK,
          PLATFORM_INTEGRATION_UNAUTHORIZED,
          PLATFORM_AUTHENTICATION_ERROR,
          TEMPORARY_ERROR,
        ];
        errors.forEach((err) => {
          it(`errors ${err}`, async () => {
            const res = await handleError(config, new Error(err));
            expect(res).toEqual(err);
          });
        });
    
        it(`handles ExternalHostError`, async () => {
          const res = await handleError(
            config,
            new ExternalHostError(new Error(), 'some-host-type')
          );
          expect(res).toEqual(EXTERNAL_HOST_ERROR);
        });
    
        it('rewrites git 5xx error', async () => {
          const gitError = new Error(
            "fatal: unable to access 'https://**redacted**@gitlab.com/learnox/learnox.git/': The requested URL returned error: 500\n"
          );
          const res = await handleError(config, gitError);
          expect(res).toEqual(EXTERNAL_HOST_ERROR);
        });
    
        it('rewrites git remote error', async () => {
          const gitError = new Error(
            'fatal: remote error: access denied or repository not exported: /b/nw/bd/27/47/159945428/108610112.git\n'
          );
          const res = await handleError(config, gitError);
          expect(res).toEqual(EXTERNAL_HOST_ERROR);
        });
    
        it('rewrites git fatal error', async () => {
          const gitError = new Error(
            'fatal: not a git repository (or any parent up to mount point /mnt)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n'
          );
          const res = await handleError(config, gitError);
          expect(res).toEqual(TEMPORARY_ERROR);
        });
    
        it('handles unknown error', async () => {
          const res = await handleError(config, new Error('abcdefg'));
          expect(res).toEqual(UNKNOWN_ERROR);
        });
      });
    });