diff --git a/lib/workers/repository/init/inherited.spec.ts b/lib/workers/repository/init/inherited.spec.ts index e31f5ba2fc32bf..5808c82d5379d0 100644 --- a/lib/workers/repository/init/inherited.spec.ts +++ b/lib/workers/repository/init/inherited.spec.ts @@ -1,4 +1,4 @@ -import { mocked, platform } from '../../../../test/util'; +import { hostRules, mocked, platform } from '../../../../test/util'; import * as presets_ from '../../../config/presets'; import type { RenovateConfig } from '../../../config/types'; import * as validation from '../../../config/validation'; @@ -91,6 +91,27 @@ describe('workers/repository/init/inherited', () => { expect(logger.warn).not.toHaveBeenCalled(); }); + it('should set hostRules from inherited config', async () => { + platform.getRawFile.mockResolvedValue( + `{ + "hostRules": [ + { + "matchHost": "some-host-url", + "token": "some-token" + } + ] + }`, + ); + const res = await mergeInheritedConfig(config); + expect(hostRules.getAll()).toMatchObject([ + { + matchHost: 'some-host-url', + token: 'some-token', + }, + ]); + expect(res.hostRules).toBeUndefined(); + }); + it('should resolve presets found in inherited config', async () => { platform.getRawFile.mockResolvedValue( '{"onboarding":false,"labels":["test"],"extends":[":automergeAll"]}', diff --git a/lib/workers/repository/init/inherited.ts b/lib/workers/repository/init/inherited.ts index 5a2796758ff56d..da497ca5aee671 100644 --- a/lib/workers/repository/init/inherited.ts +++ b/lib/workers/repository/init/inherited.ts @@ -152,6 +152,7 @@ function setInheritedHostRules(config: RenovateConfig): void { try { hostRules.add(rule); } catch (err) { + // istanbul ignore next logger.warn( { err, config: rule }, 'Error setting hostRule from config',