From a91d646b2c855a1b7274893416c25899c4ecc086 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Fri, 6 Sep 2024 19:01:33 -0300 Subject: [PATCH] refactor: Fix return type for `filterInternalChecks` function (#31259) --- .../process/lookup/filter-checks.spec.ts | 16 ++++++++-------- .../repository/process/lookup/filter-checks.ts | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/workers/repository/process/lookup/filter-checks.spec.ts b/lib/workers/repository/process/lookup/filter-checks.spec.ts index f0f01e3849..8b45e5e2b3 100644 --- a/lib/workers/repository/process/lookup/filter-checks.spec.ts +++ b/lib/workers/repository/process/lookup/filter-checks.spec.ts @@ -61,7 +61,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(0); - expect(res.release.version).toBe('1.0.4'); + expect(res.release?.version).toBe('1.0.4'); }); it('returns non-pending latest release if internalChecksFilter=flexible and none pass checks', async () => { @@ -76,7 +76,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(0); - expect(res.release.version).toBe('1.0.4'); + expect(res.release?.version).toBe('1.0.4'); }); it('returns pending latest release if internalChecksFilter=strict and none pass checks', async () => { @@ -91,7 +91,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeTrue(); expect(res.pendingReleases).toHaveLength(0); - expect(res.release.version).toBe('1.0.4'); + expect(res.release?.version).toBe('1.0.4'); }); it('returns non-latest release if internalChecksFilter=strict and some pass checks', async () => { @@ -106,7 +106,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(2); - expect(res.release.version).toBe('1.0.2'); + expect(res.release?.version).toBe('1.0.2'); }); it('returns non-latest release if internalChecksFilter=flexible and some pass checks', async () => { @@ -121,7 +121,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(2); - expect(res.release.version).toBe('1.0.2'); + expect(res.release?.version).toBe('1.0.2'); }); it('picks up minimumReleaseAge settings from hostRules', async () => { @@ -139,7 +139,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(0); - expect(res.release.version).toBe('1.0.4'); + expect(res.release?.version).toBe('1.0.4'); }); it('picks up minimumReleaseAge settings from updateType', async () => { @@ -154,7 +154,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(1); - expect(res.release.version).toBe('1.0.3'); + expect(res.release?.version).toBe('1.0.3'); }); it('picks up minimumConfidence settings from updateType', async () => { @@ -174,7 +174,7 @@ describe('workers/repository/process/lookup/filter-checks', () => { expect(res).toMatchSnapshot(); expect(res.pendingChecks).toBeFalse(); expect(res.pendingReleases).toHaveLength(3); - expect(res.release.version).toBe('1.0.1'); + expect(res.release?.version).toBe('1.0.1'); }); }); }); diff --git a/lib/workers/repository/process/lookup/filter-checks.ts b/lib/workers/repository/process/lookup/filter-checks.ts index 47fd605f15..dbe19beeb6 100644 --- a/lib/workers/repository/process/lookup/filter-checks.ts +++ b/lib/workers/repository/process/lookup/filter-checks.ts @@ -16,7 +16,7 @@ import type { LookupUpdateConfig, UpdateResult } from './types'; import { getUpdateType } from './update-type'; export interface InternalChecksResult { - release: Release; + release?: Release; pendingChecks: boolean; pendingReleases?: Release[]; } @@ -117,6 +117,5 @@ export async function filterInternalChecks( } } - // TODO #22198 - return { release: release!, pendingChecks, pendingReleases }; + return { release, pendingChecks, pendingReleases }; }