Skip to content
Snippets Groups Projects
Select Git revision
  • 1ff8c2806ceaff6970cdb98f01b3971035d05e90
  • main default protected
  • rfc-0010-kubeconfig
  • release/v2.6.x
  • dependabot/go_modules/helm.sh/helm/v3-3.18.4
  • dependabot/github_actions/ci-641206964f
  • conform-k8s-1.33
  • rfc-external-artifact
  • release/v2.5.x
  • release/v2.4.x
  • remove-notation-validation
  • release/v2.3.x
  • release/v2.2.x
  • RFC
  • fix-commit-log
  • flux-audit
  • release/v2.1.x
  • context-ns
  • ksm-dashboard
  • rfc-passwordless-git-auth
  • release/v2.0.x
  • v2.6.4 protected
  • v2.6.3 protected
  • v2.6.2 protected
  • v2.6.1 protected
  • v2.6.0 protected
  • v2.5.1 protected
  • v2.5.0 protected
  • v2.4.0 protected
  • v2.3.0 protected
  • v2.2.3 protected
  • v2.2.2 protected
  • v2.2.1 protected
  • v2.2.0 protected
  • v2.1.2 protected
  • v2.1.1 protected
  • v2.1.0 protected
  • v2.0.1 protected
  • v2.0.0 protected
  • v2.0.0-rc.5 protected
  • v2.0.0-rc.4 protected
41 results

create_source.go

Blame
  • error.spec.ts 3.37 KiB
    import { RenovateConfig, getConfig } from '../../../test/util';
    import {
      CONFIG_SECRETS_EXPOSED,
      CONFIG_VALIDATION,
      EXTERNAL_HOST_ERROR,
      MANAGER_LOCKFILE_ERROR,
      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 = getConfig();
    });
    
    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,
          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);
        });
      });
    });