Skip to content
Snippets Groups Projects
Select Git revision
  • f9f13f0f2a52185b4c9b3e6242cd931e5a6239e3
  • main default
  • bugfix/update-govmomi-for-vsphere-8
  • faleksic-main-patch-45738
  • sh-debug-docker-restart-error
  • mb-update-download-link-2024-01-31
  • il-central-1
  • update-aws-govcloud-regions
  • ajwalker/golang-upgrade
  • main-patch-3e07
  • dbickford-add-darwin-arm64-build
  • darren-patch-docs
  • debug-ssh-connections
  • DarrenEastman-main-patch-57526
  • add-command-for-base-certificates-regeneration
  • ak/go-modules
  • linux-s390x
  • contribution-warning
  • nelbacha-master-patch-89734
  • gitlab-0-14-0-release
  • test-longer-creation-waiting-time-for-DO
  • v0.16.2-gitlab.25
  • v0.16.2-gitlab.24
  • v0.16.2-gitlab.23
  • v0.16.2-gitlab.22
  • v0.16.2-gitlab.21
  • v0.16.2-gitlab.20
  • v0.16.2-gitlab.19
  • v0.16.2-gitlab.18
  • v0.16.2-gitlab.17
  • v0.16.2-gitlab.16
  • v0.16.2-gitlab.15
  • v0.16.2-gitlab.15-rc2
  • v0.16.2-gitlab.15-rc1
  • v0.16.2-gitlab.14
  • v0.16.2-gitlab.13
  • v0.16.2-gitlab.12
  • v0.16.2-gitlab.11
  • v0.16.2-gitlab.10
  • v0.16.2-gitlab.9
  • v0.16.2-gitlab.8
41 results

shell.go

Blame
  • initialize.spec.ts 2.68 KiB
    import { git, mockedFunction } from '../../../test/util';
    import type { AllConfig, RenovateConfig } from '../../config/types';
    import { initPlatform as _initPlatform } from '../../modules/platform';
    import * as hostRules from '../../util/host-rules';
    import { globalInitialize } from './initialize';
    
    jest.mock('../../util/git');
    const initPlatform = mockedFunction(_initPlatform);
    
    describe('workers/global/initialize', () => {
      beforeEach(() => {
        initPlatform.mockImplementationOnce((r) => Promise.resolve(r));
      });
    
      describe('checkVersions()', () => {
        it('throws if invalid version', async () => {
          const config: RenovateConfig = {};
          git.validateGitVersion.mockResolvedValueOnce(false);
          await expect(globalInitialize(config)).rejects.toThrow();
        });
    
        it('returns if valid git version', async () => {
          const config: RenovateConfig = { prCommitsPerRunLimit: 2 };
          git.validateGitVersion.mockResolvedValueOnce(true);
          await expect(globalInitialize(config)).toResolve();
        });
    
        it('supports containerbase', async () => {
          const config: AllConfig = { binarySource: 'docker' };
          git.validateGitVersion.mockResolvedValueOnce(true);
          await expect(globalInitialize(config)).toResolve();
        });
    
        it('supports containerbase cache dir', async () => {
          const config: AllConfig = {
            binarySource: 'docker',
            containerbaseDir: '/tmp/containerbase',
          };
          git.validateGitVersion.mockResolvedValueOnce(true);
          await expect(globalInitialize(config)).toResolve();
        });
      });
    
      describe('setGlobalHostRules', () => {
        beforeEach(() => {
          hostRules.clear();
        });
    
        it('should have run before initPlatform', async () => {
          const hostRule = {
            hostType: 'github',
            matchHost: 'https://some.github-enterprise.host',
            httpsPrivateKey: 'private-key',
            httpsCertificate: 'certificate',
            httpsCertificateAuthority: 'certificate-authority',
          };
    
          initPlatform.mockReset();
          initPlatform.mockImplementationOnce((r) => {
            const foundRule = hostRules.find({
              hostType: hostRule.hostType,
              url: hostRule.matchHost,
            });
    
            expect(foundRule.httpsPrivateKey).toEqual(hostRule.httpsPrivateKey);
            expect(foundRule.httpsCertificateAuthority).toEqual(
              hostRule.httpsCertificateAuthority,
            );
            expect(foundRule.httpsCertificate).toEqual(hostRule.httpsCertificate);
    
            return Promise.resolve(r);
          });
    
          const config: RenovateConfig = {
            hostRules: [hostRule],
          };
    
          git.validateGitVersion.mockResolvedValueOnce(true);
          await expect(globalInitialize(config)).toResolve();
        });
      });
    });