Skip to content
Snippets Groups Projects
Select Git revision
  • 468fc79f1af210a97b3f15bbf4cd00a1177a63ad
  • master default
  • rtde
  • tmp-gpg-key-workaround-2
  • tmp-gpg-key-workaround
  • 68-git-lfs-error-in-ddeploy-job
  • split-build-and-test
  • 66-jazzy-support
  • 62-deploy-jobs-do-not-pull-files-from-lfs-manual-lfs-pull
  • 62-deploy-jobs-do-not-pull-files-from-lfs-custom-docker-image
  • py3-without-industrial-ci-test
  • 58-add-yolo-pip-package-support
  • 55-collision-between-test-jobs-due-to-dds-autodiscovery-ros2
  • 52-ddeploy-job-failing-when-enforcing-labels-alt-quick-dind-test
  • 48-python3_syntax
  • 46-default-docker-image-name-too-long
  • 45-double-pipeline-triggered-if-merge-request-has-melodic-branch-name
  • 40-repo-is-ros-testing
  • test-badges
  • test-lfs-concept
  • add-packages
21 results

add-deb-sources.bash

Blame
  • validate.spec.js 3.28 KiB
    const validate = require('../../../../lib/workers/repository/finalise/validate');
    
    beforeEach(() => {
      jest.resetAllMocks();
    });
    
    describe('workers/repository/validate', () => {
      describe('validatePrs()', () => {
        it('returns if disabled', async () => {
          await validate.validatePrs({ suppressNotifications: ['prValidation'] });
        });
        it('catches error', async () => {
          platform.getPrList.mockReturnValueOnce([
            {
              state: 'open',
              branchName: 'some/branch',
              title: 'Update Renovate',
            },
          ]);
          await validate.validatePrs({});
          expect(platform.setBranchStatus).toHaveBeenCalledTimes(0);
          expect(platform.ensureComment).toHaveBeenCalledTimes(0);
          expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
        });
        it('returns if no matching files', async () => {
          platform.getPrList.mockReturnValueOnce([
            {
              state: 'open',
              branchName: 'some/branch',
              title: 'Update Renovate',
            },
          ]);
          platform.getPrFiles.mockReturnValueOnce(['readme.md']);
          await validate.validatePrs({});
          expect(platform.setBranchStatus).toHaveBeenCalledTimes(0);
          expect(platform.ensureComment).toHaveBeenCalledTimes(0);
          expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
        });
        it('validates failures if cannot parse', async () => {
          platform.getPrList.mockReturnValueOnce([
            {
              state: 'open',
              branchName: 'some/branch',
              title: 'Update Renovate',
            },
          ]);
          platform.getPrFiles.mockReturnValueOnce(['renovate.json']);
          platform.getFile.mockReturnValue('not JSON');
          await validate.validatePrs({});
          expect(platform.setBranchStatus).toHaveBeenCalledTimes(1);
          expect(platform.setBranchStatus.mock.calls[0][3]).toEqual('failure');
          expect(platform.ensureComment).toHaveBeenCalledTimes(1);
          expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
        });
        it('validates failures if config validation fails', async () => {
          platform.getPrList.mockReturnValueOnce([
            {
              state: 'open',
              branchName: 'some/branch',
              title: 'Update Renovate',
            },
          ]);
          platform.getPrFiles.mockReturnValueOnce(['renovate.json']);
          platform.getFile.mockReturnValue('{"foo":1}');
          await validate.validatePrs({});
          expect(platform.setBranchStatus).toHaveBeenCalledTimes(1);
          expect(platform.setBranchStatus.mock.calls[0][3]).toEqual('failure');
          expect(platform.ensureComment).toHaveBeenCalledTimes(1);
          expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
        });
        it('validates successfully', async () => {
          platform.getPrList.mockReturnValueOnce([
            {
              state: 'open',
              branchName: 'some/branch',
              title: 'Update Renovate',
            },
          ]);
          platform.getPrFiles.mockReturnValueOnce(['renovate.json']);
          platform.getFile.mockReturnValue('{}');
          await validate.validatePrs({});
          expect(platform.setBranchStatus).toHaveBeenCalledTimes(1);
          expect(platform.setBranchStatus.mock.calls[0][3]).toEqual('success');
          expect(platform.ensureComment).toHaveBeenCalledTimes(0);
          expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(1);
        });
      });
    });