From 6c27008dd083d9412dd9e0712d2b017bb9bcfefa Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Tue, 21 Feb 2023 04:04:10 +0530 Subject: [PATCH 1/7] test: replace as assertions for BranchUpgradeConfig objects --- .../repository/update/branch/index.spec.ts | 25 ++--- .../update/pr/changelog/release-notes.spec.ts | 48 +++++----- .../repository/updates/generate.spec.ts | 96 ++++++++++--------- 3 files changed, 87 insertions(+), 82 deletions(-) diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index 08d037066d3cbe..35323a3b0aa236 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -1597,15 +1597,14 @@ describe('workers/repository/update/branch/index', () => { fileFilters: ['modified_file', 'deleted_file'], }, upgrades: [ - { - ...getConfig(), + partial({ depName: 'some-dep-name', postUpgradeTasks: { executionMode: 'update', commands: ['echo {{{versioning}}}', 'disallowed task'], fileFilters: ['modified_file', 'deleted_file'], }, - } as BranchUpgradeConfig, + }), ], } as BranchConfig; const result = await branchWorker.processBranch(inconfig); @@ -1703,9 +1702,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - upgrades: [ + upgrades: partial([ { - ...getConfig(), depName: 'some-dep-name-1', postUpgradeTasks: { executionMode: 'update', @@ -1717,9 +1715,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - } as BranchUpgradeConfig, + }, { - ...getConfig(), depName: 'some-dep-name-2', postUpgradeTasks: { executionMode: 'update', @@ -1731,8 +1728,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - } as BranchUpgradeConfig, - ], + }, + ]), }; const result = await branchWorker.processBranch(inconfig); @@ -1852,9 +1849,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - upgrades: [ + upgrades: partial([ { - ...getConfig(), depName: 'some-dep-name-1', postUpgradeTasks: { executionMode: 'branch', @@ -1866,9 +1862,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - } as BranchUpgradeConfig, + }, { - ...getConfig(), depName: 'some-dep-name-2', postUpgradeTasks: { executionMode: 'branch', @@ -1880,8 +1875,8 @@ describe('workers/repository/update/branch/index', () => { 'modified_then_deleted_file', ], }, - } as BranchUpgradeConfig, - ], + }, + ]), }; const result = await branchWorker.processBranch(inconfig); diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index 071f42ffe7d89f..865475da3213d0 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -1,7 +1,7 @@ import { DateTime } from 'luxon'; import { Fixtures } from '../../../../../../test/fixtures'; import * as httpMock from '../../../../../../test/http-mock'; -import { mocked } from '../../../../../../test/util'; +import { mocked, partial } from '../../../../../../test/util'; import { clone } from '../../../../../util/clone'; import * as githubGraphql from '../../../../../util/github/graphql'; import * as _hostRules from '../../../../../util/host-rules'; @@ -90,16 +90,16 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { it('returns input if invalid', async () => { const input = { a: 1 }; expect( - await addReleaseNotes(input as never, {} as BranchUpgradeConfig) + await addReleaseNotes(input as never, partial({})) ).toEqual(input); // TODO #7154 expect( - await addReleaseNotes(null as never, {} as BranchUpgradeConfig) + await addReleaseNotes(null as never, partial({})) ).toBeNull(); expect( await addReleaseNotes( { versions: [] } as never, - {} as BranchUpgradeConfig + partial({}) ) ).toStrictEqual({ versions: [], @@ -116,7 +116,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { versions: [{ version: '3.10.0', compare: { url: '' } }], }; expect( - await addReleaseNotes(input as never, {} as BranchUpgradeConfig) + await addReleaseNotes(input as never, partial({})) ).toEqual({ a: 1, hasReleaseNotes: false, @@ -147,7 +147,9 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { version: '20.26.0', compare: { url: '' } } as ChangeLogRelease, ], } as ChangeLogResult; - expect(await addReleaseNotes(input, {} as BranchUpgradeConfig)).toEqual({ + expect( + await addReleaseNotes(input, partial({})) + ).toEqual({ a: 1, hasReleaseNotes: false, project: { @@ -324,7 +326,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.0', gitRef: '1.0.0', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toBeNull(); }); @@ -359,7 +361,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -401,7 +403,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: '', @@ -443,7 +445,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body\n', @@ -485,7 +487,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body\n', @@ -527,7 +529,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toBeNull(); }); @@ -562,7 +564,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -606,7 +608,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -650,7 +652,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -693,7 +695,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -731,7 +733,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -768,7 +770,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -805,7 +807,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -829,7 +831,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toBeNull(); }); @@ -872,7 +874,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.0', gitRef: '1.0.0', } as ChangeLogRelease, - {} as BranchUpgradeConfig + partial({}) ); expect(res).toEqual({ url: 'correct/url/tag.com', @@ -906,7 +908,9 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.0', gitRef: '1.0.0', } as ChangeLogRelease, - { extractVersion: 'app-(?[0-9.]*)' } as BranchUpgradeConfig + partial({ + extractVersion: 'app-(?[0-9.]*)', + }) ); expect(res).toEqual({ url: 'correct/url/tag.com', diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 557ae43779ceda..4c30528a0cb3f3 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -1,5 +1,5 @@ import { codeBlock } from 'common-tags'; -import { getConfig } from '../../../../test/util'; +import { getConfig, partial } from '../../../../test/util'; import type { RenovateConfig, UpdateType } from '../../../config/types'; import { NpmDatasource } from '../../../modules/datasource/npm'; import type { BranchUpgradeConfig } from '../../types'; @@ -15,7 +15,7 @@ beforeEach(() => { describe('workers/repository/updates/generate', () => { describe('generateBranchConfig()', () => { it('does not group single upgrade', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -28,7 +28,7 @@ describe('workers/repository/updates/generate', () => { foo: 2, }, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(1); expect(res.groupName).toBeUndefined(); @@ -36,14 +36,14 @@ describe('workers/repository/updates/generate', () => { }); it('handles lockFileMaintenance', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', branchName: 'some-branch', prTitle: 'some-title', isLockFileMaintenance: true, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res).toMatchSnapshot({ branchName: 'some-branch', @@ -60,7 +60,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles lockFileUpdate', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -72,7 +72,7 @@ describe('workers/repository/updates/generate', () => { newValue: '^1.0.0', newVersion: '1.0.1', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res).toMatchSnapshot({ branchName: 'some-branch', @@ -102,7 +102,7 @@ describe('workers/repository/updates/generate', () => { }); it('does not group same upgrades', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -125,14 +125,14 @@ describe('workers/repository/updates/generate', () => { foo: 2, }, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(1); expect(res.groupName).toBeUndefined(); }); it('groups multiple upgrades same version', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -191,7 +191,7 @@ describe('workers/repository/updates/generate', () => { releaseTimestamp: '2017-02-06T20:01:41+00:00', automerge: false, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(2); expect(res.groupName).toBeDefined(); @@ -204,7 +204,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups major updates with different versions but same newValue, no recreateClosed', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -233,14 +233,14 @@ describe('workers/repository/updates/generate', () => { isMajor: true, newMajor: 5, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.groupName).toBeDefined(); expect(res.recreateClosed).toBeFalsy(); }); it('groups multiple digest updates immortally', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -263,14 +263,14 @@ describe('workers/repository/updates/generate', () => { newDigest: 'sha256:abcdef987654321', isDigest: true, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.groupName).toBeDefined(); expect(res.recreateClosed).toBeTrue(); }); it('groups multiple upgrades different version', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'depB', @@ -309,7 +309,7 @@ describe('workers/repository/updates/generate', () => { updateType: 'minor', separateMinorPatch: true, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res).toMatchObject({ foo: 2, @@ -323,7 +323,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades different version but same value', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'depB', @@ -356,7 +356,7 @@ describe('workers/repository/updates/generate', () => { }, releaseTimestamp: '2017-02-08T20:01:41+00:00', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(2); expect(res.singleVersion).toBeUndefined(); @@ -366,7 +366,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades different value but same version', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'depB', @@ -399,7 +399,7 @@ describe('workers/repository/updates/generate', () => { }, releaseTimestamp: '2017-02-08T20:01:41+00:00', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(2); expect(res.singleVersion).toBeUndefined(); @@ -409,7 +409,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple digest updates', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'foo/bar', @@ -440,7 +440,7 @@ describe('workers/repository/updates/generate', () => { foo: 2, }, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(2); expect(res.singleVersion).toBeUndefined(); @@ -466,7 +466,7 @@ describe('workers/repository/updates/generate', () => { }); it('fixes different messages', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'depA', @@ -499,7 +499,7 @@ describe('workers/repository/updates/generate', () => { }, releaseTimestamp: '2017-02-08T20:01:41+00:00', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.foo).toBe(1); expect(res.groupName).toBeUndefined(); @@ -623,6 +623,7 @@ describe('workers/repository/updates/generate', () => { }); it('use prettyVersion in pr title when there is a v', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, @@ -649,6 +650,7 @@ describe('workers/repository/updates/generate', () => { }); it('use prettyVersion in pr title there is no v', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, @@ -675,6 +677,7 @@ describe('workers/repository/updates/generate', () => { }); it('use newMajor in pr title with v', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, @@ -699,6 +702,7 @@ describe('workers/repository/updates/generate', () => { }); it('Default commitMessageExtra pr title', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, @@ -758,7 +762,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles @types specially', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', commitBodyTable: true, @@ -795,7 +799,7 @@ describe('workers/repository/updates/generate', () => { newValue: '1.0.0', group: {}, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.recreateClosed).toBeFalse(); expect(res.groupName).toBeUndefined(); @@ -823,7 +827,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles @types specially (reversed)', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -856,7 +860,7 @@ describe('workers/repository/updates/generate', () => { labels: ['a'], group: {}, }, - ]; + ]); expect(generateBranchConfig(branch)).toMatchSnapshot({ upgrades: [ { @@ -938,7 +942,7 @@ describe('workers/repository/updates/generate', () => { }); it('combines prBodyColumns', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -949,13 +953,13 @@ describe('workers/repository/updates/generate', () => { branchName: 'some-branch', prBodyColumns: ['column-c', 'column-b', 'column-a'], }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.prBodyColumns).toEqual(['column-a', 'column-b', 'column-c']); }); it('sorts upgrades, without position first', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep1', @@ -988,7 +992,7 @@ describe('workers/repository/updates/generate', () => { newValue: '0.6.0', fileReplacePosition: undefined, }, - ]; + ]); const res = generateBranchConfig(branch); expect( res.upgrades.map((upgrade) => upgrade.fileReplacePosition) @@ -996,7 +1000,7 @@ describe('workers/repository/updates/generate', () => { }); it('passes through pendingChecks', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1013,14 +1017,14 @@ describe('workers/repository/updates/generate', () => { prTitle: 'some-title', pendingChecks: true, }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.pendingChecks).toBeTrue(); expect(res.upgrades).toHaveLength(2); }); it('filters pendingChecks', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1036,14 +1040,14 @@ describe('workers/repository/updates/generate', () => { branchName: 'some-branch', prTitle: 'some-title', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.pendingChecks).toBeUndefined(); expect(res.upgrades).toHaveLength(1); }); it('displays pending versions', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1067,7 +1071,7 @@ describe('workers/repository/updates/generate', () => { prTitle: 'Two pending versions', pendingVersions: ['1.1.0', '1.1.1'], }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.upgrades.map((u) => u.displayPending)).toStrictEqual([ '', @@ -1077,7 +1081,7 @@ describe('workers/repository/updates/generate', () => { }); it('merge excludeCommitPaths if appears in upgrade', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', depName: 'some-dep1', @@ -1101,7 +1105,7 @@ describe('workers/repository/updates/generate', () => { newValue: '0.9.0', excludeCommitPaths: ['some/path', 'some/other-manager/path'], }, - ]; + ]); const res = generateBranchConfig(branch); const excludeCommitPaths = res.excludeCommitPaths ?? []; expect(excludeCommitPaths.sort()).toStrictEqual( @@ -1133,19 +1137,20 @@ describe('workers/repository/updates/generate', () => { }); it('prevents issue with duplicating "v" character', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', branchName: 'some-branch', commitMessage: 'update to vv1.2.0', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.prTitle).toBe('update to v1.2.0'); expect(res.commitMessage).toBe('update to v1.2.0'); }); it('apply semanticCommits and commitMessagePrefix together', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, @@ -1166,7 +1171,7 @@ describe('workers/repository/updates/generate', () => { }); it('dedupes duplicate table rows', () => { - const branch: BranchUpgradeConfig[] = [ + const branch: BranchUpgradeConfig[] = partial([ { commitBodyTable: true, manager: 'some-manager', @@ -1211,7 +1216,7 @@ describe('workers/repository/updates/generate', () => { currentVersion: '5.1.1', newVersion: '5.1.2', }, - ]; + ]); const res = generateBranchConfig(branch); expect(res.commitMessage?.trim()).toBe(codeBlock` | datasource | package | from | to | @@ -1229,6 +1234,7 @@ describe('workers/repository/updates/generate', () => { }); it('using commitMessagePrefix without separator', () => { + // TODO #7154 incompatible types const branch: BranchUpgradeConfig[] = [ { ...defaultConfig, From 048daf083130c60b35f7db1b3609537538f25b08 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Thu, 23 Feb 2023 17:32:42 +0530 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Michael Kriese --- .../repository/updates/generate.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 4c30528a0cb3f3..fcda11ec0f866d 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -270,7 +270,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades different version', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'depB', @@ -323,7 +323,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades different version but same value', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'depB', @@ -366,7 +366,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades different value but same version', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'depB', @@ -409,7 +409,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple digest updates', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'foo/bar', @@ -466,7 +466,7 @@ describe('workers/repository/updates/generate', () => { }); it('fixes different messages', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'depA', @@ -762,7 +762,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles @types specially', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', commitBodyTable: true, @@ -827,7 +827,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles @types specially (reversed)', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -942,7 +942,7 @@ describe('workers/repository/updates/generate', () => { }); it('combines prBodyColumns', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -959,7 +959,7 @@ describe('workers/repository/updates/generate', () => { }); it('sorts upgrades, without position first', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep1', @@ -1000,7 +1000,7 @@ describe('workers/repository/updates/generate', () => { }); it('passes through pendingChecks', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1024,7 +1024,7 @@ describe('workers/repository/updates/generate', () => { }); it('filters pendingChecks', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1047,7 +1047,7 @@ describe('workers/repository/updates/generate', () => { }); it('displays pending versions', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -1081,7 +1081,7 @@ describe('workers/repository/updates/generate', () => { }); it('merge excludeCommitPaths if appears in upgrade', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep1', @@ -1137,7 +1137,7 @@ describe('workers/repository/updates/generate', () => { }); it('prevents issue with duplicating "v" character', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -1171,7 +1171,7 @@ describe('workers/repository/updates/generate', () => { }); it('dedupes duplicate table rows', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { commitBodyTable: true, manager: 'some-manager', From 86d856dc21444f737eec2a8acf54c884444d01c4 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 24 Feb 2023 05:35:29 +0530 Subject: [PATCH 3/7] fix lint issue --- .../update/pr/changelog/release-notes.spec.ts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index a02d50b5766b49..4b3151d61a0589 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -102,10 +102,12 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { expect( await addReleaseNotes(null, partial({})) ).toBeNull(); - await addReleaseNotes({ versions: [] }, partial({})) - ).toStrictEqual({ - versions: [], - }); + expect( + await addReleaseNotes( + { versions: [] }, + partial({}) + ) + ).toStrictEqual({ versions: [] }); }); it('returns ChangeLogResult', async () => { @@ -365,7 +367,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -407,7 +409,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -491,7 +493,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -533,7 +535,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toBeNull(); @@ -568,7 +570,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -612,7 +614,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -656,7 +658,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -699,7 +701,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -737,7 +739,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -811,7 +813,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.1', gitRef: '1.0.1', - }), + }), partial({}) ); expect(res).toEqual({ @@ -878,7 +880,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.0', gitRef: '1.0.0', - }), + }), partial({}) ); expect(res).toEqual({ @@ -912,7 +914,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { partial({ version: '1.0.0', gitRef: '1.0.0', - }), + }), partial({ extractVersion: 'app-(?[0-9.]*)', }) From d93ebaf3836fcc86c2cabbb251c6735e6f5d8537 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 24 Feb 2023 06:30:55 +0530 Subject: [PATCH 4/7] more changes --- .../execute-post-upgrade-commands.spec.ts | 4 ++-- .../repository/update/branch/index.spec.ts | 10 +++++----- .../update/pr/body/updates-table.spec.ts | 13 +++++++------ .../update/pr/changelog/github.spec.ts | 8 ++++---- .../update/pr/changelog/gitlab.spec.ts | 5 +++-- lib/workers/repository/update/pr/index.spec.ts | 17 ++++++++++++----- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts b/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts index 583a2c4d62cc1e..016715279e6e1e 100644 --- a/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts +++ b/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts @@ -10,7 +10,7 @@ jest.mock('../../../../util/git'); describe('workers/repository/update/branch/execute-post-upgrade-commands', () => { describe('postUpgradeCommandsExecutor', () => { it('handles an artifact which is a directory', async () => { - const commands: BranchUpgradeConfig[] = [ + const commands: BranchUpgradeConfig[] = partial([ { manager: 'some-manager', branchName: 'main', @@ -19,7 +19,7 @@ describe('workers/repository/update/branch/execute-post-upgrade-commands', () => commands: ['disallowed_command'], }, }, - ]; + ]); const config: BranchConfig = { manager: 'some-manager', updatedPackageFiles: [], diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index 2018e4a7622a06..51144dacaef88c 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -108,7 +108,7 @@ describe('workers/repository/update/branch/index', () => { branchName: 'renovate/some-branch', errors: [], warnings: [], - upgrades: [partial({ depName: 'some-dep-name' })], + upgrades: partial([{ depName: 'some-dep-name' }]), } as BranchConfig; schedule.isScheduledNow.mockReturnValue(true); commit.commitFilesToBranch.mockResolvedValue('123test'); @@ -185,12 +185,12 @@ describe('workers/repository/update/branch/index', () => { it('skips branch if not stabilityDays not met', async () => { schedule.isScheduledNow.mockReturnValueOnce(true); config.prCreation = 'not-pending'; - (config.upgrades as Partial[]) = [ + config.upgrades = partial([ { releaseTimestamp: '2099-12-31', stabilityDays: 1, }, - ]; + ]); const res = await branchWorker.processBranch(config); expect(res).toEqual({ branchExists: false, @@ -221,11 +221,11 @@ describe('workers/repository/update/branch/index', () => { it('processes branch if minimumConfidence is met', async () => { schedule.isScheduledNow.mockReturnValueOnce(true); config.prCreation = 'not-pending'; - (config.upgrades as Partial[]) = [ + config.upgrades = partial([ { minimumConfidence: 'high', }, - ]; + ]); mergeConfidence.isActiveConfidenceLevel.mockReturnValue(true); mergeConfidence.satisfiesConfidenceLevel.mockReturnValueOnce(true); const res = await branchWorker.processBranch(config); diff --git a/lib/workers/repository/update/pr/body/updates-table.spec.ts b/lib/workers/repository/update/pr/body/updates-table.spec.ts index 36f2154afbbcd8..588a5b4bcb1fdf 100644 --- a/lib/workers/repository/update/pr/body/updates-table.spec.ts +++ b/lib/workers/repository/update/pr/body/updates-table.spec.ts @@ -1,3 +1,4 @@ +import { partial } from '../../../../../../test/util'; import type { BranchConfig, BranchUpgradeConfig } from '../../../../types'; import { getPrUpdatesTable } from './updates-table'; @@ -15,7 +16,7 @@ describe('workers/repository/update/pr/body/updates-table', () => { }); it('checks results for getPrUpdatesTable', () => { - const upgrade0: BranchUpgradeConfig = { + const upgrade0: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { @@ -30,9 +31,9 @@ describe('workers/repository/update/pr/body/updates-table', () => { 'Package file': '{{{packageFile}}}', }, updateType: 'lockFileMaintenance', - }; + }); - const upgrade1: BranchUpgradeConfig = { + const upgrade1: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { @@ -57,9 +58,9 @@ describe('workers/repository/update/pr/body/updates-table', () => { newVersion: '1.7.0', displayFrom: '^1.7.0', displayTo: '1.7.0', - }; + }); - const upgrade2: BranchUpgradeConfig = { + const upgrade2: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { @@ -85,7 +86,7 @@ describe('workers/repository/update/pr/body/updates-table', () => { newVersion: '6.2.3', displayFrom: '^6.2.3', displayTo: '6.2.3', - }; + }); // TODO #7154 allow or filter undefined const upgrade3 = undefined as never; const configObj: BranchConfig = { diff --git a/lib/workers/repository/update/pr/changelog/github.spec.ts b/lib/workers/repository/update/pr/changelog/github.spec.ts index 7d1e4c746c72e1..1e15fb380db951 100644 --- a/lib/workers/repository/update/pr/changelog/github.spec.ts +++ b/lib/workers/repository/update/pr/changelog/github.spec.ts @@ -10,7 +10,7 @@ import { getChangeLogJSON } from '.'; jest.mock('../../../../../modules/datasource/npm'); -const upgrade: BranchUpgradeConfig = { +const upgrade: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: '', depName: 'renovate', @@ -31,7 +31,7 @@ const upgrade: BranchUpgradeConfig = { { version: '2.4.2', releaseTimestamp: '2017-12-24T03:20:46.238Z' }, { version: '2.5.2' }, ], -}; +}); describe('workers/repository/update/pr/changelog/github', () => { afterEach(() => { @@ -369,7 +369,7 @@ describe('workers/repository/update/pr/changelog/github', () => { ]) ); - const upgradeData: BranchUpgradeConfig = { + const upgradeData: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: '', depName: 'correctPrefix/target', @@ -382,7 +382,7 @@ describe('workers/repository/update/pr/changelog/github', () => { { version: '1.0.1', gitRef: '123456' }, { version: '0.1.1', gitRef: 'npm_1.0.0' }, ], - }; + }); expect( await getChangeLogJSON({ ...upgradeData, diff --git a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts index 92108071fb819f..a2f7921d4f97b0 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts @@ -1,4 +1,5 @@ import * as httpMock from '../../../../../../test/http-mock'; +import { partial } from '../../../../../../test/util'; import * as semverVersioning from '../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../util/host-rules'; import type { BranchUpgradeConfig } from '../../../../types'; @@ -6,7 +7,7 @@ import { getChangeLogJSON } from '.'; jest.mock('../../../../../modules/datasource/npm'); -const upgrade: BranchUpgradeConfig = { +const upgrade: BranchUpgradeConfig = partial({ manager: 'some-manager', branchName: '', endpoint: 'https://gitlab.com/api/v4/ ', @@ -26,7 +27,7 @@ const upgrade: BranchUpgradeConfig = { { version: '5.6.0', releaseTimestamp: '2020-02-13T15:37:00.000Z' }, { version: '5.6.1' }, ], -}; +}); const matchHost = 'https://gitlab.com/'; diff --git a/lib/workers/repository/update/pr/index.spec.ts b/lib/workers/repository/update/pr/index.spec.ts index 72abd9f414a45e..b7d6feef38239a 100644 --- a/lib/workers/repository/update/pr/index.spec.ts +++ b/lib/workers/repository/update/pr/index.spec.ts @@ -1,5 +1,12 @@ import { DateTime } from 'luxon'; -import { git, logger, mocked, platform, scm } from '../../../../../test/util'; +import { + git, + logger, + mocked, + partial, + platform, + scm, +} from '../../../../../test/util'; import { GlobalConfig } from '../../../../config/global'; import { PLATFORM_INTEGRATION_UNAUTHORIZED, @@ -620,7 +627,7 @@ describe('workers/repository/update/pr/index', () => { date: '', }; - const dummyUpgrade: BranchUpgradeConfig = { + const dummyUpgrade: BranchUpgradeConfig = partial({ branchName: sourceBranch, depType: 'foo', depName: 'bar', @@ -642,7 +649,7 @@ describe('workers/repository/update/pr/index', () => { { ...dummyRelease, version: '4.5.6' }, ], }, - }; + }); it('processes changelogs', async () => { platform.createPr.mockResolvedValueOnce(pr); @@ -695,11 +702,11 @@ describe('workers/repository/update/pr/index', () => { it('removes duplicate changelogs', async () => { platform.createPr.mockResolvedValueOnce(pr); - const upgrade: BranchUpgradeConfig = { + const upgrade: BranchUpgradeConfig = partial({ ...dummyUpgrade, sourceUrl: 'https://github.com/foo/bar', sourceDirectory: '/src', - }; + }); const res = await ensurePr({ ...config, upgrades: [upgrade, upgrade, { ...upgrade, depType: 'test' }], From 99231b4f8ee17b0a167d0410068216ccd02941c3 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 25 Feb 2023 17:16:07 +0530 Subject: [PATCH 5/7] use the new partial wrapper --- lib/modules/platform/default-scm.spec.ts | 2 +- .../update/pr/changelog/release-notes.spec.ts | 41 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/lib/modules/platform/default-scm.spec.ts b/lib/modules/platform/default-scm.spec.ts index 2ec02871c8d32d..023948fa3dacae 100644 --- a/lib/modules/platform/default-scm.spec.ts +++ b/lib/modules/platform/default-scm.spec.ts @@ -15,7 +15,7 @@ describe('modules/platform/default-scm', () => { it('delegate commitAndPush to util/git', async () => { git.commitFiles.mockResolvedValueOnce('sha'); - await defaultGitScm.commitAndPush(partial({})); + await defaultGitScm.commitAndPush(partial()); expect(git.commitFiles).toHaveBeenCalledTimes(1); }); diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index 894beb641e8bc4..9810c7dba4ad97 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -97,16 +97,13 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { it('returns input if invalid', async () => { const input = { a: 1 }; expect( - await addReleaseNotes(input as never, partial({})) + await addReleaseNotes(input as never, partial()) ).toEqual(input); expect( - await addReleaseNotes(null, partial({})) + await addReleaseNotes(null, partial()) ).toBeNull(); expect( - await addReleaseNotes( - { versions: [] }, - partial({}) - ) + await addReleaseNotes({ versions: [] }, partial()) ).toStrictEqual({ versions: [] }); }); @@ -120,7 +117,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { versions: [{ version: '3.10.0', compare: { url: '' } }], }; expect( - await addReleaseNotes(input as never, partial({})) + await addReleaseNotes(input as never, partial()) ).toEqual({ a: 1, hasReleaseNotes: false, @@ -155,7 +152,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { ], } as ChangeLogResult; expect( - await addReleaseNotes(input, partial({})) + await addReleaseNotes(input, partial()) ).toEqual({ a: 1, hasReleaseNotes: false, @@ -333,7 +330,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.0', gitRef: '1.0.0', }), - partial({}) + partial() ); expect(res).toBeNull(); }); @@ -368,7 +365,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -410,7 +407,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: '', @@ -452,7 +449,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body\n', @@ -494,7 +491,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body\n', @@ -536,7 +533,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toBeNull(); }); @@ -571,7 +568,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -615,7 +612,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -659,7 +656,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -702,7 +699,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n', @@ -740,7 +737,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -777,7 +774,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -814,7 +811,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.1', gitRef: '1.0.1', }), - partial({}) + partial() ); expect(res).toEqual({ body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)', @@ -881,7 +878,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { version: '1.0.0', gitRef: '1.0.0', }), - partial({}) + partial() ); expect(res).toEqual({ url: 'correct/url/tag.com', From 8aca8f49fa46fc7bb486b219f84dd0d10360b741 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 25 Feb 2023 22:03:09 +0530 Subject: [PATCH 6/7] apply suggestions --- .../branch/execute-post-upgrade-commands.spec.ts | 2 +- .../update/pr/body/updates-table.spec.ts | 6 +++--- .../repository/update/pr/changelog/github.spec.ts | 4 ++-- .../repository/update/pr/changelog/gitlab.spec.ts | 2 +- lib/workers/repository/update/pr/index.spec.ts | 4 ++-- lib/workers/repository/updates/generate.spec.ts | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts b/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts index 016715279e6e1e..242f1b37d2af83 100644 --- a/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts +++ b/lib/workers/repository/update/branch/execute-post-upgrade-commands.spec.ts @@ -10,7 +10,7 @@ jest.mock('../../../../util/git'); describe('workers/repository/update/branch/execute-post-upgrade-commands', () => { describe('postUpgradeCommandsExecutor', () => { it('handles an artifact which is a directory', async () => { - const commands: BranchUpgradeConfig[] = partial([ + const commands = partial([ { manager: 'some-manager', branchName: 'main', diff --git a/lib/workers/repository/update/pr/body/updates-table.spec.ts b/lib/workers/repository/update/pr/body/updates-table.spec.ts index 588a5b4bcb1fdf..e321e930eb5f4f 100644 --- a/lib/workers/repository/update/pr/body/updates-table.spec.ts +++ b/lib/workers/repository/update/pr/body/updates-table.spec.ts @@ -16,7 +16,7 @@ describe('workers/repository/update/pr/body/updates-table', () => { }); it('checks results for getPrUpdatesTable', () => { - const upgrade0: BranchUpgradeConfig = partial({ + const upgrade0 = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { @@ -33,7 +33,7 @@ describe('workers/repository/update/pr/body/updates-table', () => { updateType: 'lockFileMaintenance', }); - const upgrade1: BranchUpgradeConfig = partial({ + const upgrade1 = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { @@ -60,7 +60,7 @@ describe('workers/repository/update/pr/body/updates-table', () => { displayTo: '1.7.0', }); - const upgrade2: BranchUpgradeConfig = partial({ + const upgrade2 = partial({ manager: 'some-manager', branchName: 'some-branch', prBodyDefinitions: { diff --git a/lib/workers/repository/update/pr/changelog/github.spec.ts b/lib/workers/repository/update/pr/changelog/github.spec.ts index 1e15fb380db951..84419c7e26ff32 100644 --- a/lib/workers/repository/update/pr/changelog/github.spec.ts +++ b/lib/workers/repository/update/pr/changelog/github.spec.ts @@ -10,7 +10,7 @@ import { getChangeLogJSON } from '.'; jest.mock('../../../../../modules/datasource/npm'); -const upgrade: BranchUpgradeConfig = partial({ +const upgrade = partial({ manager: 'some-manager', branchName: '', depName: 'renovate', @@ -369,7 +369,7 @@ describe('workers/repository/update/pr/changelog/github', () => { ]) ); - const upgradeData: BranchUpgradeConfig = partial({ + const upgradeData = partial({ manager: 'some-manager', branchName: '', depName: 'correctPrefix/target', diff --git a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts index a2f7921d4f97b0..5f9828046e31e3 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts @@ -7,7 +7,7 @@ import { getChangeLogJSON } from '.'; jest.mock('../../../../../modules/datasource/npm'); -const upgrade: BranchUpgradeConfig = partial({ +const upgrade = partial({ manager: 'some-manager', branchName: '', endpoint: 'https://gitlab.com/api/v4/ ', diff --git a/lib/workers/repository/update/pr/index.spec.ts b/lib/workers/repository/update/pr/index.spec.ts index b7d6feef38239a..425bc8d3bd6232 100644 --- a/lib/workers/repository/update/pr/index.spec.ts +++ b/lib/workers/repository/update/pr/index.spec.ts @@ -627,7 +627,7 @@ describe('workers/repository/update/pr/index', () => { date: '', }; - const dummyUpgrade: BranchUpgradeConfig = partial({ + const dummyUpgrade = partial({ branchName: sourceBranch, depType: 'foo', depName: 'bar', @@ -702,7 +702,7 @@ describe('workers/repository/update/pr/index', () => { it('removes duplicate changelogs', async () => { platform.createPr.mockResolvedValueOnce(pr); - const upgrade: BranchUpgradeConfig = partial({ + const upgrade = partial({ ...dummyUpgrade, sourceUrl: 'https://github.com/foo/bar', sourceDirectory: '/src', diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 77f63627eb117b..2f436d4bf62d8a 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -15,7 +15,7 @@ beforeEach(() => { describe('workers/repository/updates/generate', () => { describe('generateBranchConfig()', () => { it('does not group single upgrade', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -36,7 +36,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles lockFileMaintenance', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -60,7 +60,7 @@ describe('workers/repository/updates/generate', () => { }); it('handles lockFileUpdate', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', branchName: 'some-branch', @@ -102,7 +102,7 @@ describe('workers/repository/updates/generate', () => { }); it('does not group same upgrades', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -132,7 +132,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple upgrades same version', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -204,7 +204,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups major updates with different versions but same newValue, no recreateClosed', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', @@ -240,7 +240,7 @@ describe('workers/repository/updates/generate', () => { }); it('groups multiple digest updates immortally', () => { - const branch: BranchUpgradeConfig[] = partial([ + const branch = partial([ { manager: 'some-manager', depName: 'some-dep', From 18996255bc4b8a95ef58bbe4ec453a4a376d35c9 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 25 Feb 2023 22:07:14 +0530 Subject: [PATCH 7/7] apply suggestions*2 --- lib/workers/repository/update/pr/changelog/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/repository/update/pr/changelog/index.spec.ts b/lib/workers/repository/update/pr/changelog/index.spec.ts index c99c2f0e877a06..51748a88e5aaf0 100644 --- a/lib/workers/repository/update/pr/changelog/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/index.spec.ts @@ -14,7 +14,7 @@ const githubApiHost = 'https://api.github.com'; const githubTagsMock = jest.spyOn(githubGraphql, 'queryTags'); const githubReleasesMock = jest.spyOn(githubGraphql, 'queryReleases'); -const upgrade: BranchConfig = partial({ +const upgrade = partial({ endpoint: 'https://api.github.com/', depName: 'renovate', versioning: semverVersioning.id,