0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/manager/hermit/extract.spec.ts
Yun Lai b696abb3c2
feat: add Hermit package manager (#16258)
* feat: add Hermit package manager

* fix: pass bin directory into getRepoStatus as string rather than an array

* fix: fix up hermit manager implementations

* add docker support in exec
* move fs related operations back into  util/fs
* remove ENVVar passed on by process.env
* set concurrency in pMap
* use for instead of pMap for concurrency = 1
* use regex to pick up package reference parts

* fix: fix manager updateArtifacts test after change

* Update lib/modules/manager/hermit/extract.ts

Co-authored-by: Philip <42116482+PhilipAbed@users.noreply.github.com>

* fix: fix up test and docker reference for hermit manager

* test refer to internal fs
* docker image change to sidecar
* only symlink are read for the changed file content after hermit
  install
* no more global mock in artifacts test

* fix: use warn instead of error so error better flows up in hermit manager

* fix: partial for test type, use throw instead of reject

* fix: update snapshot

* fix: combine install packages, also make extractPackageFile async

* fix: remove weird generated readLocalSynmlink in test

* fix: removes old test

* fix: use ensureLocalPath and fix test coverage

* fix: more test coverage

* fix: use ensureLocalPath in readLocalSymlink

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* fix: remove unused functions and types

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* Apply suggestions from code review

Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>

* fix: use execSnapshots and for of loop when returning the result

* Update lib/modules/manager/hermit/artifacts.spec.ts

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* fix: move exports below imports

Co-authored-by: Philip <42116482+PhilipAbed@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
2022-07-30 08:41:45 +00:00

84 lines
2.3 KiB
TypeScript

import { mockedFunction } from '../../../../test/util';
import { readLocalDirectory } from '../../../util/fs';
import { HermitDatasource } from '../../datasource/hermit';
import { extractPackageFile } from './extract';
jest.mock('../../../util/fs');
const readdirMock = mockedFunction(readLocalDirectory);
describe('modules/manager/hermit/extract', () => {
describe('extractPackageFile', () => {
it('should list packages on command success', async () => {
const ret = [
'.go-1.17.9.pkg',
'go',
'.golangci-lint-1.40.0.pkg',
'golangci-lint',
'.jq@stable.pkg',
'jq',
'.somepackage-invalid-version.pkg',
];
readdirMock.mockResolvedValue(ret);
const rootPackages = await extractPackageFile('', 'bin/hermit');
expect(rootPackages).toStrictEqual({
deps: [
{
datasource: HermitDatasource.id,
depName: 'go',
currentValue: `1.17.9`,
},
{
datasource: HermitDatasource.id,
depName: 'golangci-lint',
currentValue: `1.40.0`,
},
{
datasource: HermitDatasource.id,
depName: 'jq',
currentValue: `@stable`,
},
],
});
const nestedRet = [
'.gradle-7.4.2.pkg',
'go',
'.openjdk-11.0.11_9-zulu11.48.21.pkg',
'java',
'.maven@3.8.pkg',
'maven',
];
readdirMock.mockResolvedValue(nestedRet);
const nestedPackages = await extractPackageFile('', 'nested/bin/hermit');
expect(nestedPackages).toStrictEqual({
deps: [
{
datasource: HermitDatasource.id,
depName: 'gradle',
currentValue: '7.4.2',
},
{
datasource: HermitDatasource.id,
depName: 'openjdk',
currentValue: `11.0.11_9-zulu11.48.21`,
},
{
datasource: HermitDatasource.id,
depName: 'maven',
currentValue: '@3.8',
},
],
});
});
it('should throw error on execution failure', async () => {
const msg = 'error reading directory';
readdirMock.mockRejectedValue(new Error(msg));
expect(await extractPackageFile('', 'bin/hermit')).toBeNull();
});
});
});