diff --git a/lib/modules/manager/index.spec.ts b/lib/modules/manager/index.spec.ts index 1c635b82ff6dfe..d1f7ee871f2fd0 100644 --- a/lib/modules/manager/index.spec.ts +++ b/lib/modules/manager/index.spec.ts @@ -170,7 +170,7 @@ describe('modules/manager/index', () => { }); describe('getRangeStrategy', () => { - it('returns null', () => { + it('returns null for a unknown manager', () => { manager.getManagers().set('dummy', { defaultConfig: {}, supportedDatasources: [], @@ -180,6 +180,25 @@ describe('modules/manager/index', () => { ).toBeNull(); }); + it('returns null for a undefined manager', () => { + manager.getManagers().set('dummy', { + defaultConfig: {}, + supportedDatasources: [], + }); + expect(manager.getRangeStrategy({ rangeStrategy: 'auto' })).toBeNull(); + }); + + it('handles custom managers', () => { + customManager.getCustomManagers().set('dummy', { + defaultConfig: {}, + supportedDatasources: [], + getRangeStrategy: () => 'bump', + }); + expect( + manager.getRangeStrategy({ manager: 'dummy', rangeStrategy: 'auto' }), + ).toBe('bump'); + }); + it('returns non-null', () => { manager.getManagers().set('dummy', { defaultConfig: {}, diff --git a/lib/modules/manager/index.ts b/lib/modules/manager/index.ts index e4f9eace2969a3..fb40089e86e979 100644 --- a/lib/modules/manager/index.ts +++ b/lib/modules/manager/index.ts @@ -78,10 +78,13 @@ export function extractPackageFile( export function getRangeStrategy(config: RangeConfig): RangeStrategy | null { const { manager, rangeStrategy } = config; - if (!manager || !managers.has(manager)) { + if (!manager) { + return null; + } + const m = managers.get(manager)! ?? customManagers.get(manager)!; + if (!m) { return null; } - const m = managers.get(manager)!; if (m.getRangeStrategy) { // Use manager's own function if it exists const managerRangeStrategy = m.getRangeStrategy(config);