mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
ff6761ed23
* fix(config/global): return default values for `GlobalConfig.get` As noted in #39949, it can be awkward working with in `GlobalConfig.get`, where we would previously need to specify the default value when calling `.get`, which could lead to drift with the defaults for a given config option. To reduce this risk, we can rely on a given `default` for a configuration option, providing that as a default. Because this now definitely returns a value that matches the config option, it now allows us to remove `!` assertions. * fixup! fix(config/global): return default values for `GlobalConfig.get` Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * fixup! fix(config/global): return default values for `GlobalConfig.get` * test(presets): remove impossible test As it's now not possible to set a value as `undefined` (as `GlobalConfig` will then use the default), this test no longer validates anything. * test(workers/repository): add mock Now `platform` defaults to `github`, we need to mock out the call to fetch config. Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io> * test: coverage * test: coverage --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
import type { RenovateConfig } from '~test/util.ts';
|
|
import { logger, partial } from '~test/util.ts';
|
|
import { GlobalConfig } from '../../../config/global.ts';
|
|
import * as _secrets from '../../../config/secrets.ts';
|
|
import * as _onboarding from '../onboarding/branch/index.ts';
|
|
import * as _apis from './apis.ts';
|
|
import * as _config from './config.ts';
|
|
import { initRepo } from './index.ts';
|
|
import * as _merge from './merge.ts';
|
|
|
|
vi.mock('../onboarding/branch/index.ts');
|
|
vi.mock('../configured.ts');
|
|
vi.mock('../init/apis.ts');
|
|
vi.mock('../init/config.ts');
|
|
vi.mock('../init/merge.ts');
|
|
vi.mock('../../../config/secrets.ts');
|
|
vi.mock('../../../config/variables.ts');
|
|
vi.mock('../../../modules/platform/index.ts', () => ({
|
|
platform: { initRepo: vi.fn() },
|
|
getPlatformList: vi.fn(),
|
|
}));
|
|
vi.unmock('../../../util/mutex.ts');
|
|
|
|
const apis = vi.mocked(_apis);
|
|
const config = vi.mocked(_config);
|
|
const merge = vi.mocked(_merge);
|
|
const onboarding = vi.mocked(_onboarding);
|
|
const secrets = vi.mocked(_secrets);
|
|
|
|
describe('workers/repository/init/index', () => {
|
|
beforeEach(() => {
|
|
GlobalConfig.set({ localDir: '', cacheDir: '' });
|
|
});
|
|
|
|
afterEach(() => {
|
|
GlobalConfig.reset();
|
|
});
|
|
|
|
describe('initRepo', () => {
|
|
it('runs', async () => {
|
|
apis.initApis.mockResolvedValue(partial<_apis.WorkerPlatformConfig>());
|
|
onboarding.checkOnboardingBranch.mockResolvedValueOnce({});
|
|
config.getRepoConfig.mockResolvedValueOnce({ mode: 'silent' });
|
|
merge.mergeRenovateConfig.mockResolvedValueOnce({});
|
|
secrets.applySecretsAndVariablesToConfig.mockReturnValueOnce(
|
|
partial<RenovateConfig>(),
|
|
);
|
|
const renovateConfig = await initRepo({});
|
|
expect(renovateConfig).toEqual({});
|
|
});
|
|
|
|
it('warns on unsupported options', async () => {
|
|
apis.initApis.mockResolvedValue(partial<_apis.WorkerPlatformConfig>());
|
|
onboarding.checkOnboardingBranch.mockResolvedValueOnce({});
|
|
config.getRepoConfig.mockResolvedValueOnce({
|
|
filterUnavailableUsers: true,
|
|
expandCodeOwnersGroups: true,
|
|
});
|
|
merge.mergeRenovateConfig.mockResolvedValueOnce({});
|
|
secrets.applySecretsAndVariablesToConfig.mockReturnValueOnce(
|
|
partial<RenovateConfig>(),
|
|
);
|
|
await initRepo({});
|
|
|
|
expect(logger.logger.warn).toHaveBeenCalledWith(
|
|
{ platform: 'github' },
|
|
"Configuration option 'filterUnavailableUsers' is not supported on the current platform.",
|
|
);
|
|
|
|
expect(logger.logger.warn).toHaveBeenCalledWith(
|
|
{ platform: 'github' },
|
|
"Configuration option 'expandCodeOwnersGroups' is not supported on the current platform.",
|
|
);
|
|
});
|
|
});
|
|
});
|