mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
b4319928f1
* refactor: strict manager tests * chore: revert changes * Update lib/modules/manager/gradle/extract.spec.ts
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import _simpleGit, { Response, SimpleGit } from 'simple-git';
|
|
import { DirectoryResult, dir } from 'tmp-promise';
|
|
import { join } from 'upath';
|
|
import { GlobalConfig } from '../../../config/global';
|
|
import type { RepoGlobalConfig } from '../../../config/types';
|
|
import type { Upgrade } from '../types';
|
|
import { updateDependency } from '.';
|
|
|
|
jest.mock('simple-git');
|
|
const simpleGit: jest.Mock<Partial<SimpleGit>> = _simpleGit as never;
|
|
|
|
describe('modules/manager/git-submodules/update', () => {
|
|
describe('updateDependency', () => {
|
|
let upgrade: Upgrade;
|
|
let adminConfig: RepoGlobalConfig;
|
|
let tmpDir: DirectoryResult;
|
|
|
|
beforeAll(async () => {
|
|
upgrade = { depName: 'renovate' };
|
|
|
|
tmpDir = await dir({ unsafeCleanup: true });
|
|
adminConfig = { localDir: join(tmpDir.path) };
|
|
GlobalConfig.set(adminConfig);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await tmpDir.cleanup();
|
|
GlobalConfig.reset();
|
|
});
|
|
|
|
it('returns null on error', async () => {
|
|
simpleGit.mockReturnValue({
|
|
submoduleUpdate() {
|
|
throw new Error();
|
|
},
|
|
});
|
|
const update = await updateDependency({
|
|
fileContent: '',
|
|
upgrade,
|
|
});
|
|
expect(update).toBeNull();
|
|
});
|
|
|
|
it('returns content on update', async () => {
|
|
simpleGit.mockReturnValue({
|
|
submoduleUpdate() {
|
|
return Promise.resolve('') as Response<string>;
|
|
},
|
|
checkout() {
|
|
return Promise.resolve('') as Response<string>;
|
|
},
|
|
});
|
|
const update = await updateDependency({
|
|
fileContent: '',
|
|
upgrade,
|
|
});
|
|
expect(update).toBe('');
|
|
});
|
|
});
|
|
});
|