Skip to content
Snippets Groups Projects
Select Git revision
  • 5ab1cefe2c00777ca268538d1c7a7057bd87dfe0
  • main default protected
  • next
  • renovate/main-redis-5.x
  • chore/update-static-data
  • feat/gnupg
  • 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
  • gh-readonly-queue/next/pr-35009-046ebf7cb84ab859f7fefceb5fa53a54ce9736f8
  • 41.62.4
  • 41.62.3
  • 41.62.2
  • 41.62.1
  • 41.62.0
  • 41.61.1
  • 41.61.0
  • 41.60.4
  • 41.60.3
  • 41.60.2
  • 41.60.1
  • 41.60.0
  • 41.59.2
  • 41.59.1
  • 41.59.0
  • 41.58.2
  • 41.58.1
  • 41.58.0
  • 41.57.1
  • 41.57.0
41 results

flatten.spec.ts

Blame
  • flatten.spec.ts 5.41 KiB
    import { RenovateConfig, getConfig } from '../../../../test/util';
    import { flattenUpdates } from './flatten';
    
    jest.mock('../../../util/git/semantic');
    
    let config: RenovateConfig;
    
    beforeEach(() => {
      jest.resetAllMocks();
      config = getConfig();
      config.errors = [];
      config.warnings = [];
    });
    
    describe('workers/repository/updates/flatten', () => {
      describe('flattenUpdates()', () => {
        it('flattens', async () => {
          // TODO #7154
          config.lockFileMaintenance!.enabled = true;
          config.packageRules = [
            {
              matchUpdateTypes: ['minor'],
              automerge: true,
            },
            {
              matchPaths: ['frontend/package.json'],
              lockFileMaintenance: {
                enabled: false,
              },
            },
          ];
          config.remediations = {
            'package-lock.json': [
              {
                datasoource: 'npm',
                depName: 'foo',
                currentVersion: '1.2.0',
                newVersion: '1.3.0',
                prBodyNotes: '',
              },
            ],
          };
          const packageFiles = {
            npm: [
              {
                packageFile: 'package.json',
                lockFiles: ['package-lock.json'],
                deps: [
                  {
                    depName: '@org/a',
                    updates: [
                      {
                        newValue: '1.0.0',
                        sourceUrl: 'https://github.com/org/repo',
                      },
                    ],
                  },
                  {
                    depName: 'foo',
                    updates: [
                      {
                        newValue: '2.0.0',
                        sourceUrl: 'https://github.com/org/repo',
                      },
                    ],
                  },
                  {
                    updateTypes: ['pin'],
                    updates: [{ newValue: '2.0.0' }],
                  },
                  {
                    depName: 'abc',
                    updates: [
                      {
                        newName: 'def',
                        newValue: '2.0.0',
                        updateType: 'replacement',
                      },
                    ],
                  },
                ],
              },
              {
                packageFile: 'backend/package.json',
                deps: [
                  {
                    depName: 'bar',
                    updates: [{ newValue: '3.0.0', sourceUrl: 3 }],
                  },
                ],
              },
              {
                packageFile: 'frontend/package.json',
                deps: [{ depName: 'baz', updates: [{ newValue: '3.0.1' }] }],
              },
            ],
            dockerfile: [
              {
                packageFile: 'Dockerfile',
                deps: [
                  {
                    depName: 'amd64/node',
                    language: 'docker',
                    sourceUrl: 'https://github.com/nodejs/node',
                    updates: [{ newValue: '10.0.1' }],
                  },
                ],
              },
              {
                packageFile: 'Dockerfile',
                deps: [
                  {
                    depName: 'calico/node',
                    language: 'docker',
                    sourceUrl: 'https://calico.com',
                    updates: [{ newValue: '3.2.0', updateType: 'minor' }],
                  },
                ],
              },
            ],
            gomod: [
              {
                packageFile: 'go.mod',
                deps: [
                  {
                    depName: 'github.com/Parallels/docker-machine-parallels',
                    updates: [{ newValue: '1.3.0' }],
                  },
                  {
                    depName: 'gopkg.in/yaml.v2',
                    updates: [{ newValue: '2.2.8', updateType: 'minor' }],
                  },
                  {
                    depName: 'gopkg.in/warnings.v0',
                    updates: [{ newValue: '0.1.3' }],
                  },
                  {
                    depName: 'github.com/blang/semver',
                    updates: [],
                  },
                ],
              },
            ],
          };
          const res = await flattenUpdates(config, packageFiles);
          expect(res).toHaveLength(14);
          expect(
            res.filter((update) => update.sourceRepoSlug)[0].sourceRepoSlug
          ).toBe('org-repo');
          expect(res.filter((update) => update.sourceRepo)[0].sourceRepo).toBe(
            'org/repo'
          );
          expect(
            res.filter((update) => update.sourceRepoOrg)[0].sourceRepoOrg
          ).toBe('org');
          expect(
            res.filter((update) => update.sourceRepoName)[0].sourceRepoName
          ).toBe('repo');
          expect(
            res.filter((update) => update.sourceRepoSlug)[1].sourceRepoSlug
          ).toBe('org-repo');
          expect(res.filter((update) => update.sourceRepo)[1].sourceRepo).toBe(
            'org/repo'
          );
          expect(
            res.filter((update) => update.sourceRepoOrg)[1].sourceRepoOrg
          ).toBe('org');
          expect(
            res.filter((update) => update.sourceRepoName)[1].sourceRepoName
          ).toBe('repo');
          expect(
            res.filter((update) => update.sourceRepoSlug)[2].sourceRepoSlug
          ).toBe('nodejs-node');
          expect(res.filter((update) => update.sourceRepo)[2].sourceRepo).toBe(
            'nodejs/node'
          );
          expect(
            res.filter((update) => update.sourceRepoOrg)[2].sourceRepoOrg
          ).toBe('nodejs');
          expect(
            res.filter((update) => update.sourceRepoName)[2].sourceRepoName
          ).toBe('node');
          expect(
            res.filter(
              (r) =>
                r.updateType === 'lockFileMaintenance' && r.isLockFileMaintenance
            )
          ).toHaveLength(2);
          expect(res.filter((r) => r.isVulnerabilityAlert)).toHaveLength(1);
        });
      });
    });