0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/workers/repository/reconfigure/reconfigure-cache.spec.ts
RahulGautamSingh 32340dbc47
feat(config): validate reconfigure branch (#24699)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-11-03 13:31:49 +00:00

59 lines
1.8 KiB
TypeScript

import { mocked } from '../../../../test/util';
import * as _cache from '../../../util/cache/repository';
import type { RepoCacheData } from '../../../util/cache/repository/types';
import {
deleteReconfigureBranchCache,
setReconfigureBranchCache,
} from './reconfigure-cache';
jest.mock('../../../util/cache/repository');
const cache = mocked(_cache);
describe('workers/repository/reconfigure/reconfigure-cache', () => {
describe('setReconfigureBranchCache()', () => {
it('sets new cache', () => {
const dummyCache = {} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
setReconfigureBranchCache('reconfigure-sha', false);
expect(dummyCache).toEqual({
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
});
});
it('updates old cache', () => {
const dummyCache = {
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
setReconfigureBranchCache('reconfigure-sha-1', false);
expect(dummyCache).toEqual({
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha-1',
isConfigValid: false,
},
});
});
});
describe('deleteReconfigureBranchCache()', () => {
it('deletes cache', () => {
const dummyCache = {
reconfigureBranchCache: {
reconfigureBranchSha: 'reconfigure-sha',
isConfigValid: false,
},
} satisfies RepoCacheData;
cache.getCache.mockReturnValue(dummyCache);
deleteReconfigureBranchCache();
expect(dummyCache.reconfigureBranchCache).toBeUndefined();
});
});
});