mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 05:56:26 +00:00
refactor: introduce Fixtures util class (#12638)
* refactor: introduce Fixtures util class * refactor: align yarn.spec * refactor: move fs mocks to __mocks__ folder * refactor: improve fs-extra mock * refactor: move callsite to dev deps * refactor: use fixtures class * refactor: use fixtures class * refactor: reduce external variables in tests * refactor: improve Fixtures * refactor: add type for realFs * refactor: remove obsolete snapshot * fix: by comments * refactor: provide ability to spy on mocked fs methods * refactor: fix build * refactor: fix by comments * refactor: add docs * refactor: fix unit test * refactor: return called times checks * refactor: fix by comments * refactor: adjust unit test * refactor: adjust unit test * refactor: fix unit test * refactor: fix by comments * refactor: fix by comments * refactor: update jsdoc * refactor: fix by comments Co-authored-by: Rhys Arkins <rhys@arkins.net> Co-authored-by: Jamie Magee <jamie.magee@gmail.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
38a6119154
commit
dabe3d0e29
54 changed files with 428 additions and 337 deletions
3
__mocks__/fs.ts
Normal file
3
__mocks__/fs.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { fs } from 'memfs';
|
||||||
|
|
||||||
|
module.exports = fs;
|
|
@ -1,10 +1,10 @@
|
||||||
import { loadFixture } from '../../test/util';
|
import { Fixtures } from '../../test/fixtures';
|
||||||
import { decryptConfig } from './decrypt';
|
import { decryptConfig } from './decrypt';
|
||||||
import { GlobalConfig } from './global';
|
import { GlobalConfig } from './global';
|
||||||
import type { RenovateConfig } from './types';
|
import type { RenovateConfig } from './types';
|
||||||
|
|
||||||
const privateKey = loadFixture('private.pem', '.');
|
const privateKey = Fixtures.get('private.pem');
|
||||||
const privateKeyPgp = loadFixture('private-pgp.pem', '.');
|
const privateKeyPgp = Fixtures.get('private-pgp.pem');
|
||||||
const repository = 'abc/def';
|
const repository = 'abc/def';
|
||||||
|
|
||||||
describe('config/decrypt', () => {
|
describe('config/decrypt', () => {
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import { range } from '../../util/range';
|
import { range } from '../../util/range';
|
||||||
import { datasource, defaultRegistryUrl, pageSize } from './common';
|
import { datasource, defaultRegistryUrl, pageSize } from './common';
|
||||||
|
|
||||||
const res1 = loadFixture('page.json');
|
|
||||||
const jre = loadFixture('jre.json');
|
|
||||||
|
|
||||||
function getPath(page: number, imageType = 'jdk'): string {
|
function getPath(page: number, imageType = 'jdk'): string {
|
||||||
return `/v3/info/release_versions?page_size=${pageSize}&image_type=${imageType}&project=jdk&release_type=ga&sort_method=DATE&sort_order=DESC&vendor=adoptium&page=${page}`;
|
return `/v3/info/release_versions?page_size=${pageSize}&image_type=${imageType}&project=jdk&release_type=ga&sort_method=DATE&sort_order=DESC&vendor=adoptium&page=${page}`;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +70,10 @@ describe('datasource/adoptium-java/index', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('processes real data', async () => {
|
it('processes real data', async () => {
|
||||||
httpMock.scope(defaultRegistryUrl).get(getPath(0)).reply(200, res1);
|
httpMock
|
||||||
|
.scope(defaultRegistryUrl)
|
||||||
|
.get(getPath(0))
|
||||||
|
.reply(200, Fixtures.get('page.json'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName,
|
depName,
|
||||||
|
@ -83,7 +83,10 @@ describe('datasource/adoptium-java/index', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('processes real data (jre)', async () => {
|
it('processes real data (jre)', async () => {
|
||||||
httpMock.scope(defaultRegistryUrl).get(getPath(0, 'jre')).reply(200, jre);
|
httpMock
|
||||||
|
.scope(defaultRegistryUrl)
|
||||||
|
.get(getPath(0, 'jre'))
|
||||||
|
.reply(200, Fixtures.get('jre.json'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName: 'java-jre',
|
depName: 'java-jre',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { joinUrlParts } from '../../util/url';
|
import { joinUrlParts } from '../../util/url';
|
||||||
|
@ -14,8 +14,8 @@ const testConfig = {
|
||||||
registryUrls: [testRegistryUrl],
|
registryUrls: [testRegistryUrl],
|
||||||
depName: testLookupName,
|
depName: testLookupName,
|
||||||
};
|
};
|
||||||
const fixtureReleasesAsFolders = loadFixture('releases-as-folders.html');
|
const fixtureReleasesAsFolders = Fixtures.get('releases-as-folders.html');
|
||||||
const fixtureReleasesAsFiles = loadFixture('releases-as-files.html');
|
const fixtureReleasesAsFiles = Fixtures.get('releases-as-files.html');
|
||||||
|
|
||||||
function getPath(folder: string): string {
|
function getPath(folder: string): string {
|
||||||
return `/${folder}`;
|
return `/${folder}`;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import { CdnJsDatasource } from '.';
|
import { CdnJsDatasource } from '.';
|
||||||
|
|
||||||
const res1 = loadFixture('d3-force.json');
|
|
||||||
const res2 = loadFixture('bulma.json');
|
|
||||||
|
|
||||||
const baseUrl = 'https://api.cdnjs.com/';
|
const baseUrl = 'https://api.cdnjs.com/';
|
||||||
|
|
||||||
const pathFor = (s: string): string =>
|
const pathFor = (s: string): string =>
|
||||||
|
@ -105,7 +102,7 @@ describe('datasource/cdnjs/index', () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope(baseUrl)
|
.scope(baseUrl)
|
||||||
.get(pathFor('d3-force/d3-force.js'))
|
.get(pathFor('d3-force/d3-force.js'))
|
||||||
.reply(200, res1);
|
.reply(200, Fixtures.get('d3-force.json'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource: CdnJsDatasource.id,
|
datasource: CdnJsDatasource.id,
|
||||||
depName: 'd3-force/d3-force.js',
|
depName: 'd3-force/d3-force.js',
|
||||||
|
@ -117,7 +114,7 @@ describe('datasource/cdnjs/index', () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope(baseUrl)
|
.scope(baseUrl)
|
||||||
.get(pathFor('bulma/only/0.7.5/style.css'))
|
.get(pathFor('bulma/only/0.7.5/style.css'))
|
||||||
.reply(200, res2);
|
.reply(200, Fixtures.get('bulma.json'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource: CdnJsDatasource.id,
|
datasource: CdnJsDatasource.id,
|
||||||
depName: 'bulma/only/0.7.5/style.css',
|
depName: 'bulma/only/0.7.5/style.css',
|
||||||
|
|
|
@ -4,8 +4,8 @@ import _simpleGit from 'simple-git';
|
||||||
import { DirectoryResult, dir } from 'tmp-promise';
|
import { DirectoryResult, dir } from 'tmp-promise';
|
||||||
import { dirname, join } from 'upath';
|
import { dirname, join } from 'upath';
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { GlobalConfig } from '../../config/global';
|
import { GlobalConfig } from '../../config/global';
|
||||||
import type { RepoGlobalConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as memCache from '../../util/cache/memory';
|
import * as memCache from '../../util/cache/memory';
|
||||||
|
@ -15,10 +15,6 @@ import { CrateDatasource } from '.';
|
||||||
jest.mock('simple-git');
|
jest.mock('simple-git');
|
||||||
const simpleGit: any = _simpleGit;
|
const simpleGit: any = _simpleGit;
|
||||||
|
|
||||||
const res1 = loadFixture('libc');
|
|
||||||
const res2 = loadFixture('amethyst');
|
|
||||||
const res3 = loadFixture('mypkg');
|
|
||||||
|
|
||||||
const baseUrl =
|
const baseUrl =
|
||||||
'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/';
|
'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/';
|
||||||
|
|
||||||
|
@ -36,7 +32,7 @@ function setupGitMocks(delayMs?: number): { mockClone: jest.Mock<any, any> } {
|
||||||
|
|
||||||
const path = `${clonePath}/my/pk/mypkg`;
|
const path = `${clonePath}/my/pk/mypkg`;
|
||||||
fs.mkdirSync(dirname(path), { recursive: true });
|
fs.mkdirSync(dirname(path), { recursive: true });
|
||||||
fs.writeFileSync(path, res3, { encoding: 'utf8' });
|
fs.writeFileSync(path, Fixtures.get('mypkg'), { encoding: 'utf8' });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -209,7 +205,10 @@ describe('datasource/crate/index', () => {
|
||||||
expect(httpMock.getTrace()).toMatchSnapshot();
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('processes real data: libc', async () => {
|
it('processes real data: libc', async () => {
|
||||||
httpMock.scope(baseUrl).get('/li/bc/libc').reply(200, res1);
|
httpMock
|
||||||
|
.scope(baseUrl)
|
||||||
|
.get('/li/bc/libc')
|
||||||
|
.reply(200, Fixtures.get('libc'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName: 'libc',
|
depName: 'libc',
|
||||||
|
@ -221,7 +220,10 @@ describe('datasource/crate/index', () => {
|
||||||
expect(httpMock.getTrace()).toMatchSnapshot();
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('processes real data: amethyst', async () => {
|
it('processes real data: amethyst', async () => {
|
||||||
httpMock.scope(baseUrl).get('/am/et/amethyst').reply(200, res2);
|
httpMock
|
||||||
|
.scope(baseUrl)
|
||||||
|
.get('/am/et/amethyst')
|
||||||
|
.reply(200, Fixtures.get('amethyst'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName: 'amethyst',
|
depName: 'amethyst',
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import { GalaxyCollectionDatasource } from '.';
|
import { GalaxyCollectionDatasource } from '.';
|
||||||
|
|
||||||
const communityKubernetesBase = loadFixture('community_kubernetes_base.json');
|
const communityKubernetesBase = Fixtures.get('community_kubernetes_base.json');
|
||||||
const communityKubernetesVersions = loadFixture(
|
const communityKubernetesVersions = Fixtures.get(
|
||||||
'community_kubernetes_versions.json'
|
'community_kubernetes_versions.json'
|
||||||
);
|
);
|
||||||
const communityKubernetesDetails121 = loadFixture(
|
const communityKubernetesDetails121 = Fixtures.get(
|
||||||
'community_kubernetes_version_details_1.2.1.json'
|
'community_kubernetes_version_details_1.2.1.json'
|
||||||
);
|
);
|
||||||
const communityKubernetesDetails120 = loadFixture(
|
const communityKubernetesDetails120 = Fixtures.get(
|
||||||
'community_kubernetes_version_details_1.2.0.json'
|
'community_kubernetes_version_details_1.2.0.json'
|
||||||
);
|
);
|
||||||
const communityKubernetesDetails0111 = loadFixture(
|
const communityKubernetesDetails0111 = Fixtures.get(
|
||||||
'community_kubernetes_version_details_0.11.1.json'
|
'community_kubernetes_version_details_0.11.1.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { GalaxyDatasource } from '.';
|
import { GalaxyDatasource } from '.';
|
||||||
|
|
||||||
const res1 = loadFixture('timezone');
|
|
||||||
const empty = loadFixture('empty');
|
|
||||||
|
|
||||||
const baseUrl = 'https://galaxy.ansible.com/';
|
const baseUrl = 'https://galaxy.ansible.com/';
|
||||||
|
|
||||||
describe('datasource/galaxy/index', () => {
|
describe('datasource/galaxy/index', () => {
|
||||||
|
@ -79,7 +76,7 @@ describe('datasource/galaxy/index', () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope(baseUrl)
|
.scope(baseUrl)
|
||||||
.get('/api/v1/roles/?owner__username=yatesr&name=timezone')
|
.get('/api/v1/roles/?owner__username=yatesr&name=timezone')
|
||||||
.reply(200, res1);
|
.reply(200, Fixtures.get('timezone'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource: GalaxyDatasource.id,
|
datasource: GalaxyDatasource.id,
|
||||||
depName: 'yatesr.timezone',
|
depName: 'yatesr.timezone',
|
||||||
|
@ -93,7 +90,7 @@ describe('datasource/galaxy/index', () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope(baseUrl)
|
.scope(baseUrl)
|
||||||
.get('/api/v1/roles/?owner__username=foo&name=bar')
|
.get('/api/v1/roles/?owner__username=foo&name=bar')
|
||||||
.reply(200, empty);
|
.reply(200, Fixtures.get('empty'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource: GalaxyDatasource.id,
|
datasource: GalaxyDatasource.id,
|
||||||
depName: 'foo.bar',
|
depName: 'foo.bar',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import _simpleGit from 'simple-git';
|
import _simpleGit from 'simple-git';
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { GitRefsDatasource } from '.';
|
import { GitRefsDatasource } from '.';
|
||||||
|
|
||||||
jest.mock('simple-git');
|
jest.mock('simple-git');
|
||||||
|
@ -8,7 +8,7 @@ const simpleGit: any = _simpleGit;
|
||||||
|
|
||||||
const depName = 'https://github.com/example/example.git';
|
const depName = 'https://github.com/example/example.git';
|
||||||
|
|
||||||
const lsRemote1 = loadFixture('ls-remote-1.txt');
|
const lsRemote1 = Fixtures.get('ls-remote-1.txt');
|
||||||
|
|
||||||
const datasource = GitRefsDatasource.id;
|
const datasource = GitRefsDatasource.id;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import _simpleGit from 'simple-git';
|
import _simpleGit from 'simple-git';
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { GitTagsDatasource } from '.';
|
import { GitTagsDatasource } from '.';
|
||||||
|
|
||||||
jest.mock('simple-git');
|
jest.mock('simple-git');
|
||||||
|
@ -8,7 +8,7 @@ const simpleGit: any = _simpleGit;
|
||||||
|
|
||||||
const depName = 'https://github.com/example/example.git';
|
const depName = 'https://github.com/example/example.git';
|
||||||
|
|
||||||
const lsRemote1 = loadFixture('ls-remote-1.txt', '../git-refs');
|
const lsRemote1 = Fixtures.get('ls-remote-1.txt', '../git-refs');
|
||||||
|
|
||||||
const datasource = GitTagsDatasource.id;
|
const datasource = GitTagsDatasource.id;
|
||||||
const datasourceInstance = new GitTagsDatasource();
|
const datasourceInstance = new GitTagsDatasource();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { HelmDatasource } from '.';
|
import { HelmDatasource } from '.';
|
||||||
|
|
||||||
// Truncated index.yaml file
|
// Truncated index.yaml file
|
||||||
const indexYaml = loadFixture('index.yaml');
|
const indexYaml = Fixtures.get('index.yaml');
|
||||||
|
|
||||||
describe('datasource/helm/index', () => {
|
describe('datasource/helm/index', () => {
|
||||||
describe('getReleases', () => {
|
describe('getReleases', () => {
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import { datasource, defaultRegistryUrl } from './common';
|
import { datasource, defaultRegistryUrl } from './common';
|
||||||
|
|
||||||
const res1 = loadFixture('index.json');
|
|
||||||
|
|
||||||
describe('datasource/node/index', () => {
|
describe('datasource/node/index', () => {
|
||||||
describe('getReleases', () => {
|
describe('getReleases', () => {
|
||||||
it('throws for 500', async () => {
|
it('throws for 500', async () => {
|
||||||
|
@ -42,7 +40,10 @@ describe('datasource/node/index', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('processes real data', async () => {
|
it('processes real data', async () => {
|
||||||
httpMock.scope(defaultRegistryUrl).get('/index.json').reply(200, res1);
|
httpMock
|
||||||
|
.scope(defaultRegistryUrl)
|
||||||
|
.get('/index.json')
|
||||||
|
.reply(200, Fixtures.get('index.json'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName: 'node',
|
depName: 'node',
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { RubyVersionDatasource } from '.';
|
import { RubyVersionDatasource } from '.';
|
||||||
|
|
||||||
const rubyReleasesHtml = loadFixture('releases.html');
|
|
||||||
|
|
||||||
const datasource = RubyVersionDatasource.id;
|
const datasource = RubyVersionDatasource.id;
|
||||||
|
|
||||||
describe('datasource/ruby-version/index', () => {
|
describe('datasource/ruby-version/index', () => {
|
||||||
|
@ -13,7 +11,7 @@ describe('datasource/ruby-version/index', () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope('https://www.ruby-lang.org')
|
.scope('https://www.ruby-lang.org')
|
||||||
.get('/en/downloads/releases/')
|
.get('/en/downloads/releases/')
|
||||||
.reply(200, rubyReleasesHtml);
|
.reply(200, Fixtures.get('releases.html'));
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
depName: 'ruby',
|
depName: 'ruby',
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import * as mavenVersioning from '../../versioning/maven';
|
import * as mavenVersioning from '../../versioning/maven';
|
||||||
import { MAVEN_REPO } from '../maven/common';
|
import { MAVEN_REPO } from '../maven/common';
|
||||||
import { parseIndexDir } from '../sbt-plugin/util';
|
import { parseIndexDir } from '../sbt-plugin/util';
|
||||||
import * as sbtPackage from '.';
|
import * as sbtPackage from '.';
|
||||||
|
|
||||||
const mavenIndexHtml = loadFixture(`maven-index.html`);
|
|
||||||
const sbtPluginIndex = loadFixture(`sbt-plugins-index.html`);
|
|
||||||
|
|
||||||
describe('datasource/sbt-package/index', () => {
|
describe('datasource/sbt-package/index', () => {
|
||||||
it('parses Maven index directory', () => {
|
it('parses Maven index directory', () => {
|
||||||
expect(parseIndexDir(mavenIndexHtml)).toMatchSnapshot();
|
expect(parseIndexDir(Fixtures.get(`maven-index.html`))).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses sbt index directory', () => {
|
it('parses sbt index directory', () => {
|
||||||
expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot();
|
expect(
|
||||||
|
parseIndexDir(Fixtures.get(`sbt-plugins-index.html`))
|
||||||
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getPkgReleases', () => {
|
describe('getPkgReleases', () => {
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const yamlFile1 = loadFixture('main1.yaml');
|
|
||||||
const yamlFile2 = loadFixture('main2.yaml');
|
|
||||||
|
|
||||||
describe('manager/ansible/extract', () => {
|
describe('manager/ansible/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts multiple image lines from docker_container', () => {
|
it('extracts multiple image lines from docker_container', () => {
|
||||||
const res = extractPackageFile(yamlFile1);
|
const res = extractPackageFile(Fixtures.get('main1.yaml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(9);
|
expect(res.deps).toHaveLength(9);
|
||||||
});
|
});
|
||||||
it('extracts multiple image lines from docker_service', () => {
|
it('extracts multiple image lines from docker_service', () => {
|
||||||
const res = extractPackageFile(yamlFile2);
|
const res = extractPackageFile(Fixtures.get('main2.yaml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(4);
|
expect(res.deps).toHaveLength(4);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const validApplication = loadFixture('validApplication.yml');
|
const validApplication = Fixtures.get('validApplication.yml');
|
||||||
const malformedApplication = loadFixture('malformedApplications.yml');
|
const malformedApplication = Fixtures.get('malformedApplications.yml');
|
||||||
const randomManifest = loadFixture('randomManifest.yml');
|
const randomManifest = Fixtures.get('randomManifest.yml');
|
||||||
|
|
||||||
describe('manager/argocd/extract', () => {
|
describe('manager/argocd/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import {
|
import {
|
||||||
extractContainer,
|
extractContainer,
|
||||||
extractPackageFile,
|
extractPackageFile,
|
||||||
|
@ -6,11 +6,11 @@ import {
|
||||||
parseAzurePipelines,
|
parseAzurePipelines,
|
||||||
} from './extract';
|
} from './extract';
|
||||||
|
|
||||||
const azurePipelines = loadFixture('azure-pipelines.yaml');
|
const azurePipelines = Fixtures.get('azure-pipelines.yaml');
|
||||||
|
|
||||||
const azurePipelinesInvalid = loadFixture('azure-pipelines-invalid.yaml');
|
const azurePipelinesInvalid = Fixtures.get('azure-pipelines-invalid.yaml');
|
||||||
|
|
||||||
const azurePipelinesNoDependency = loadFixture(
|
const azurePipelinesNoDependency = Fixtures.get(
|
||||||
'azure-pipelines-no-dependency.yaml'
|
'azure-pipelines-no-dependency.yaml'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { id as githubReleaseDatasource } from '../../datasource/github-releases';
|
import { id as githubReleaseDatasource } from '../../datasource/github-releases';
|
||||||
import { id as semverVersioning } from '../../versioning/semver';
|
import { id as semverVersioning } from '../../versioning/semver';
|
||||||
import type { PackageDependency } from '../types';
|
import type { PackageDependency } from '../types';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const validWrapperContent = loadFixture('valid-wrapper');
|
|
||||||
const malformedWrapperContent = loadFixture('malformed-wrapper');
|
|
||||||
|
|
||||||
describe('manager/batect-wrapper/extract', () => {
|
describe('manager/batect-wrapper/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty wrapper file', () => {
|
it('returns null for empty wrapper file', () => {
|
||||||
|
@ -18,7 +15,7 @@ describe('manager/batect-wrapper/extract', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts the current version from a valid wrapper script', () => {
|
it('extracts the current version from a valid wrapper script', () => {
|
||||||
const res = extractPackageFile(validWrapperContent);
|
const res = extractPackageFile(Fixtures.get('valid-wrapper'));
|
||||||
|
|
||||||
const expectedDependency: PackageDependency = {
|
const expectedDependency: PackageDependency = {
|
||||||
depName: 'batect/batect',
|
depName: 'batect/batect',
|
||||||
|
@ -32,7 +29,7 @@ describe('manager/batect-wrapper/extract', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the first version from a wrapper script with multiple versions', () => {
|
it('returns the first version from a wrapper script with multiple versions', () => {
|
||||||
const res = extractPackageFile(malformedWrapperContent);
|
const res = extractPackageFile(Fixtures.get('malformed-wrapper'));
|
||||||
|
|
||||||
const expectedDependency: PackageDependency = {
|
const expectedDependency: PackageDependency = {
|
||||||
depName: 'batect/batect',
|
depName: 'batect/batect',
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from './../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const workspaceFile = loadFixture('WORKSPACE1');
|
|
||||||
const workspace2File = loadFixture('WORKSPACE2');
|
|
||||||
const workspace3File = loadFixture('WORKSPACE3');
|
|
||||||
const fileWithBzlExtension = loadFixture('repositories.bzl');
|
|
||||||
|
|
||||||
describe('manager/bazel/extract', () => {
|
describe('manager/bazel/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns empty if fails to parse', () => {
|
it('returns empty if fails to parse', () => {
|
||||||
|
@ -17,12 +12,12 @@ describe('manager/bazel/extract', () => {
|
||||||
expect(res).toBeNull();
|
expect(res).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts multiple types of dependencies', () => {
|
it('extracts multiple types of dependencies', () => {
|
||||||
const res = extractPackageFile(workspaceFile);
|
const res = extractPackageFile(Fixtures.get('WORKSPACE1'));
|
||||||
expect(res.deps).toHaveLength(14);
|
expect(res.deps).toHaveLength(14);
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('extracts github tags', () => {
|
it('extracts github tags', () => {
|
||||||
const res = extractPackageFile(workspace2File);
|
const res = extractPackageFile(Fixtures.get('WORKSPACE2'));
|
||||||
expect(res.deps).toMatchSnapshot([
|
expect(res.deps).toMatchSnapshot([
|
||||||
{ lookupName: 'lmirosevic/GBDeviceInfo' },
|
{ lookupName: 'lmirosevic/GBDeviceInfo' },
|
||||||
{ lookupName: 'nelhage/rules_boost' },
|
{ lookupName: 'nelhage/rules_boost' },
|
||||||
|
@ -31,11 +26,11 @@ describe('manager/bazel/extract', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
it('handle comments and strings', () => {
|
it('handle comments and strings', () => {
|
||||||
const res = extractPackageFile(workspace3File);
|
const res = extractPackageFile(Fixtures.get('WORKSPACE3'));
|
||||||
expect(res.deps).toMatchSnapshot([{ lookupName: 'nelhage/rules_boost' }]);
|
expect(res.deps).toMatchSnapshot([{ lookupName: 'nelhage/rules_boost' }]);
|
||||||
});
|
});
|
||||||
it('extracts dependencies from *.bzl files', () => {
|
it('extracts dependencies from *.bzl files', () => {
|
||||||
const res = extractPackageFile(fileWithBzlExtension);
|
const res = extractPackageFile(Fixtures.get('repositories.bzl'));
|
||||||
expect(res.deps).toMatchSnapshot([
|
expect(res.deps).toMatchSnapshot([
|
||||||
{
|
{
|
||||||
currentDigest: '0356bef3fbbabec5f0e196ecfacdeb6db62d48c0',
|
currentDigest: '0356bef3fbbabec5f0e196ecfacdeb6db62d48c0',
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const bitbucketPipelinesYAML = loadFixture('bitbucket-pipelines.yaml');
|
|
||||||
|
|
||||||
describe('manager/bitbucket-pipelines/extract', () => {
|
describe('manager/bitbucket-pipelines/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
|
@ -10,7 +8,7 @@ describe('manager/bitbucket-pipelines/extract', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts dependencies', () => {
|
it('extracts dependencies', () => {
|
||||||
const res = extractPackageFile(bitbucketPipelinesYAML);
|
const res = extractPackageFile(Fixtures.get('bitbucket-pipelines.yaml'));
|
||||||
expect(res.deps).toMatchInlineSnapshot(`
|
expect(res.deps).toMatchInlineSnapshot(`
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const pipeline1 = loadFixture('pipeline1.yml');
|
|
||||||
const pipeline2 = loadFixture('pipeline2.yml');
|
|
||||||
const pipeline3 = loadFixture('pipeline3.yml');
|
|
||||||
const pipeline4 = loadFixture('pipeline4.yml');
|
|
||||||
const pipeline5 = loadFixture('pipeline5.yml');
|
|
||||||
|
|
||||||
describe('manager/buildkite/extract', () => {
|
describe('manager/buildkite/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts simple single plugin', () => {
|
it('extracts simple single plugin', () => {
|
||||||
const res = extractPackageFile(pipeline1).deps;
|
const res = extractPackageFile(Fixtures.get('pipeline1.yml')).deps;
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res).toHaveLength(1);
|
expect(res).toHaveLength(1);
|
||||||
});
|
});
|
||||||
it('extracts multiple plugins in same file', () => {
|
it('extracts multiple plugins in same file', () => {
|
||||||
const res = extractPackageFile(pipeline2).deps;
|
const res = extractPackageFile(Fixtures.get('pipeline2.yml')).deps;
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res).toHaveLength(2);
|
expect(res).toHaveLength(2);
|
||||||
});
|
});
|
||||||
it('adds skipReason', () => {
|
it('adds skipReason', () => {
|
||||||
const res = extractPackageFile(pipeline3).deps;
|
const res = extractPackageFile(Fixtures.get('pipeline3.yml')).deps;
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res).toHaveLength(2);
|
expect(res).toHaveLength(2);
|
||||||
});
|
});
|
||||||
it('extracts arrays of plugins', () => {
|
it('extracts arrays of plugins', () => {
|
||||||
const res = extractPackageFile(pipeline4).deps;
|
const res = extractPackageFile(Fixtures.get('pipeline4.yml')).deps;
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res).toHaveLength(4);
|
expect(res).toHaveLength(4);
|
||||||
});
|
});
|
||||||
it('extracts git-based plugins', () => {
|
it('extracts git-based plugins', () => {
|
||||||
const res = extractPackageFile(pipeline5).deps;
|
const res = extractPackageFile(Fixtures.get('pipeline5.yml')).deps;
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res).toHaveLength(2);
|
expect(res).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const content = loadFixture('build.cake');
|
|
||||||
|
|
||||||
describe('manager/cake/index', () => {
|
describe('manager/cake/index', () => {
|
||||||
it('extracts', () => {
|
it('extracts', () => {
|
||||||
expect(extractPackageFile(content)).toMatchSnapshot({
|
expect(extractPackageFile(Fixtures.get('build.cake'))).toMatchSnapshot({
|
||||||
deps: [
|
deps: [
|
||||||
{ depName: 'Foo.Foo', currentValue: '1.1.1' },
|
{ depName: 'Foo.Foo', currentValue: '1.1.1' },
|
||||||
{ depName: 'Bim.Bim', currentValue: '6.6.6' },
|
{ depName: 'Bim.Bim', currentValue: '6.6.6' },
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const input = loadFixture(`sample.txt`);
|
|
||||||
|
|
||||||
describe('manager/cdnurl/extract', () => {
|
describe('manager/cdnurl/extract', () => {
|
||||||
it('extractPackageFile', () => {
|
it('extractPackageFile', () => {
|
||||||
expect(extractPackageFile(input)).toMatchSnapshot({
|
expect(extractPackageFile(Fixtures.get(`sample.txt`))).toMatchSnapshot({
|
||||||
deps: [
|
deps: [
|
||||||
{
|
{
|
||||||
depName: 'prop-types',
|
depName: 'prop-types',
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const file1 = loadFixture('cloudbuild.yml');
|
|
||||||
|
|
||||||
describe('manager/cloudbuild/extract', () => {
|
describe('manager/cloudbuild/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts multiple image lines', () => {
|
it('extracts multiple image lines', () => {
|
||||||
const res = extractPackageFile(file1);
|
const res = extractPackageFile(Fixtures.get('cloudbuild.yml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(3);
|
expect(res.deps).toHaveLength(3);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const depsEdn = loadFixture('deps.edn');
|
|
||||||
|
|
||||||
describe('manager/deps-edn/extract', () => {
|
describe('manager/deps-edn/extract', () => {
|
||||||
it('extractPackageFile', () => {
|
it('extractPackageFile', () => {
|
||||||
const { deps } = extractPackageFile(depsEdn);
|
const { deps } = extractPackageFile(Fixtures.get('deps.edn'));
|
||||||
expect(deps).toMatchSnapshot([
|
expect(deps).toMatchSnapshot([
|
||||||
{
|
{
|
||||||
depName: 'persistent-sorted-set:persistent-sorted-set',
|
depName: 'persistent-sorted-set:persistent-sorted-set',
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
|
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const droneYAML = loadFixture('.drone.yml');
|
|
||||||
|
|
||||||
describe('manager/droneci/extract', () => {
|
describe('manager/droneci/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
|
@ -11,7 +9,7 @@ describe('manager/droneci/extract', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts multiple image lines', () => {
|
it('extracts multiple image lines', () => {
|
||||||
const res = extractPackageFile(droneYAML);
|
const res = extractPackageFile(Fixtures.get('.drone.yml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(4);
|
expect(res.deps).toHaveLength(4);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const workflow1 = loadFixture('workflow_1.yml');
|
|
||||||
const workflow2 = loadFixture('workflow_2.yml');
|
|
||||||
|
|
||||||
describe('manager/github-actions/extract', () => {
|
describe('manager/github-actions/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts multiple docker image lines from yaml configuration file', () => {
|
it('extracts multiple docker image lines from yaml configuration file', () => {
|
||||||
const res = extractPackageFile(workflow1);
|
const res = extractPackageFile(Fixtures.get('workflow_1.yml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps.filter((d) => d.datasource === 'docker')).toHaveLength(2);
|
expect(res.deps.filter((d) => d.datasource === 'docker')).toHaveLength(2);
|
||||||
});
|
});
|
||||||
it('extracts multiple action tag lines from yaml configuration file', () => {
|
it('extracts multiple action tag lines from yaml configuration file', () => {
|
||||||
const res = extractPackageFile(workflow2);
|
const res = extractPackageFile(Fixtures.get('workflow_2.yml'));
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(
|
expect(
|
||||||
res.deps.filter((d) => d.datasource === 'github-tags')
|
res.deps.filter((d) => d.datasource === 'github-tags')
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const gomod1 = loadFixture('1/go.mod');
|
const gomod1 = Fixtures.get('1/go.mod');
|
||||||
const gomod2 = loadFixture('2/go.mod');
|
const gomod2 = Fixtures.get('2/go.mod');
|
||||||
const gomod3 = loadFixture('3/go.mod');
|
const gomod3 = Fixtures.get('3/go.mod');
|
||||||
|
|
||||||
describe('manager/gomod/extract', () => {
|
describe('manager/gomod/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import type { UpdateType } from '../../config/types';
|
import type { UpdateType } from '../../config/types';
|
||||||
import { updateDependency } from './update';
|
import { updateDependency } from './update';
|
||||||
|
|
||||||
const gomod1 = loadFixture('1/go.mod');
|
const gomod1 = Fixtures.get('1/go.mod');
|
||||||
const gomod2 = loadFixture('2/go.mod');
|
const gomod2 = Fixtures.get('2/go.mod');
|
||||||
|
|
||||||
describe('manager/gomod/update', () => {
|
describe('manager/gomod/update', () => {
|
||||||
describe('updateDependency', () => {
|
describe('updateDependency', () => {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const multidocYaml = loadFixture('multidoc.yaml');
|
|
||||||
|
|
||||||
describe('manager/helmfile/extract', () => {
|
describe('manager/helmfile/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -184,11 +182,15 @@ describe('manager/helmfile/extract', () => {
|
||||||
|
|
||||||
it('parses multidoc yaml', () => {
|
it('parses multidoc yaml', () => {
|
||||||
const fileName = 'helmfile.yaml';
|
const fileName = 'helmfile.yaml';
|
||||||
const result = extractPackageFile(multidocYaml, fileName, {
|
const result = extractPackageFile(
|
||||||
aliases: {
|
Fixtures.get('multidoc.yaml'),
|
||||||
stable: 'https://charts.helm.sh/stable',
|
fileName,
|
||||||
},
|
{
|
||||||
});
|
aliases: {
|
||||||
|
stable: 'https://charts.helm.sh/stable',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
expect(result).toMatchSnapshot({
|
expect(result).toMatchSnapshot({
|
||||||
datasource: 'helm',
|
datasource: 'helm',
|
||||||
deps: [
|
deps: [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { ClojureDatasource } from '../../datasource/clojure';
|
import { ClojureDatasource } from '../../datasource/clojure';
|
||||||
import {
|
import {
|
||||||
extractFromVectors,
|
extractFromVectors,
|
||||||
|
@ -7,7 +7,7 @@ import {
|
||||||
trimAtKey,
|
trimAtKey,
|
||||||
} from './extract';
|
} from './extract';
|
||||||
|
|
||||||
const leinProjectClj = loadFixture(`project.clj`);
|
const leinProjectClj = Fixtures.get(`project.clj`);
|
||||||
|
|
||||||
describe('manager/leiningen/extract', () => {
|
describe('manager/leiningen/extract', () => {
|
||||||
it('trimAtKey', () => {
|
it('trimAtKey', () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackage, extractRegistries } from './extract';
|
import { extractPackage, extractRegistries } from './extract';
|
||||||
|
|
||||||
const minimumContent = loadFixture(`minimum.pom.xml`);
|
const minimumContent = Fixtures.get(`minimum.pom.xml`);
|
||||||
const simpleContent = loadFixture(`simple.pom.xml`);
|
const simpleContent = Fixtures.get(`simple.pom.xml`);
|
||||||
|
|
||||||
const mirrorSettingsContent = loadFixture(`mirror.settings.xml`);
|
const mirrorSettingsContent = Fixtures.get(`mirror.settings.xml`);
|
||||||
const profileSettingsContent = loadFixture(`profile.settings.xml`);
|
const profileSettingsContent = Fixtures.get(`profile.settings.xml`);
|
||||||
const complexSettingsContent = loadFixture(`complex.settings.xml`);
|
const complexSettingsContent = Fixtures.get(`complex.settings.xml`);
|
||||||
|
|
||||||
describe('manager/maven/extract', () => {
|
describe('manager/maven/extract', () => {
|
||||||
describe('extractDependencies', () => {
|
describe('extractDependencies', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const input01Content = loadFixture('package-1.js');
|
const input01Content = Fixtures.get('package-1.js');
|
||||||
|
|
||||||
describe('manager/meteor/extract', () => {
|
describe('manager/meteor/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { GlobalConfig } from '../../config/global';
|
import { GlobalConfig } from '../../config/global';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const sample = loadFixture('mix.exs');
|
|
||||||
|
|
||||||
describe('manager/mix/extract', () => {
|
describe('manager/mix/extract', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
GlobalConfig.set({ localDir: '' });
|
GlobalConfig.set({ localDir: '' });
|
||||||
|
@ -15,7 +13,7 @@ describe('manager/mix/extract', () => {
|
||||||
expect(deps).toBeEmpty();
|
expect(deps).toBeEmpty();
|
||||||
});
|
});
|
||||||
it('extracts all dependencies', async () => {
|
it('extracts all dependencies', async () => {
|
||||||
const res = await extractPackageFile(sample, 'mix.exs');
|
const res = await extractPackageFile(Fixtures.get('mix.exs'), 'mix.exs');
|
||||||
expect(res).toMatchSnapshot({
|
expect(res).toMatchSnapshot({
|
||||||
deps: [
|
deps: [
|
||||||
{ depName: 'postgrex', currentValue: '~> 0.8.1' },
|
{ depName: 'postgrex', currentValue: '~> 0.8.1' },
|
||||||
|
|
|
@ -56,7 +56,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -76,7 +76,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "npx yarn-deduplicate --strategy fewer",
|
"cmd": "npx yarn-deduplicate --strategy fewer",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -96,7 +96,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -116,7 +116,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "npx yarn-deduplicate --strategy highest",
|
"cmd": "npx yarn-deduplicate --strategy highest",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -136,7 +136,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
"cmd": "yarn install --ignore-engines --ignore-platform --network-timeout 100000 --ignore-scripts",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -161,7 +161,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install",
|
"cmd": "yarn install",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -190,7 +190,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install",
|
"cmd": "yarn install",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -214,7 +214,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn dedupe --strategy highest",
|
"cmd": "yarn dedupe --strategy highest",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -243,7 +243,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn install --mode=update-lockfile",
|
"cmd": "yarn install --mode=update-lockfile",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
@ -266,7 +266,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"cmd": "yarn dedupe --strategy highest --mode=update-lockfile",
|
"cmd": "yarn dedupe --strategy highest --mode=update-lockfile",
|
||||||
"options": Object {
|
"options": Object {
|
||||||
"cwd": "some-dir",
|
"cwd": "/some-dir",
|
||||||
"encoding": "utf-8",
|
"encoding": "utf-8",
|
||||||
"env": Object {
|
"env": Object {
|
||||||
"CI": "true",
|
"CI": "true",
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
import { exec as _exec } from 'child_process';
|
import { exec as _exec } from 'child_process';
|
||||||
|
import fs from 'fs-extra';
|
||||||
import {
|
import {
|
||||||
ExecSnapshots,
|
ExecSnapshots,
|
||||||
envMock,
|
envMock,
|
||||||
mockExecAll,
|
mockExecAll,
|
||||||
} from '../../../../test/exec-util';
|
} from '../../../../test/exec-util';
|
||||||
import { fs, mocked } from '../../../../test/util';
|
import { Fixtures } from '../../../../test/fixtures';
|
||||||
|
import { mocked } from '../../../../test/util';
|
||||||
import * as _env from '../../../util/exec/env';
|
import * as _env from '../../../util/exec/env';
|
||||||
import * as _yarnHelper from './yarn';
|
import * as yarnHelper from './yarn';
|
||||||
|
|
||||||
|
jest.mock('fs-extra', () =>
|
||||||
|
require('../../../../test/fixtures').Fixtures.fsExtra()
|
||||||
|
);
|
||||||
jest.mock('child_process');
|
jest.mock('child_process');
|
||||||
jest.mock('../../../util/exec/env');
|
jest.mock('../../../util/exec/env');
|
||||||
jest.mock('../../../util/fs');
|
|
||||||
jest.mock('./node-version');
|
jest.mock('./node-version');
|
||||||
|
|
||||||
const exec: jest.Mock<typeof _exec> = _exec as any;
|
const exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
const yarnHelper = mocked(_yarnHelper);
|
|
||||||
|
|
||||||
delete process.env.NPM_CONFIG_CACHE;
|
delete process.env.NPM_CONFIG_CACHE;
|
||||||
|
|
||||||
|
@ -28,7 +31,8 @@ const fixSnapshots = (snapshots: ExecSnapshots): ExecSnapshots =>
|
||||||
|
|
||||||
describe('manager/npm/post-update/yarn', () => {
|
describe('manager/npm/post-update/yarn', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
Fixtures.reset();
|
||||||
|
jest.clearAllMocks();
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
});
|
});
|
||||||
|
@ -41,20 +45,17 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
])(
|
])(
|
||||||
'generates lock files using yarn v%s',
|
'generates lock files using yarn v%s',
|
||||||
async (yarnVersion, yarnCompatibility, expectedFsCalls) => {
|
async (yarnVersion, yarnCompatibility, expectedFsCalls) => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'.yarnrc': 'yarn-path ./.yarn/cli.js\n',
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'/some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: yarnVersion,
|
stdout: yarnVersion,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
|
||||||
if (filename.endsWith('.yarnrc')) {
|
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('yarn-path ./.yarn/cli.js\n')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('package-lock-contents')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: yarnCompatibility,
|
yarn: yarnCompatibility,
|
||||||
|
@ -62,7 +63,7 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
postUpdateOptions: ['yarnDedupeFewer', 'yarnDedupeHighest'],
|
postUpdateOptions: ['yarnDedupeFewer', 'yarnDedupeHighest'],
|
||||||
};
|
};
|
||||||
const res = await yarnHelper.generateLockFile(
|
const res = await yarnHelper.generateLockFile(
|
||||||
'some-dir',
|
'/some-dir',
|
||||||
{
|
{
|
||||||
YARN_CACHE_FOLDER: '/tmp/renovate/cache/yarn',
|
YARN_CACHE_FOLDER: '/tmp/renovate/cache/yarn',
|
||||||
YARN_GLOBAL_FOLDER: '/tmp/renovate/cache/berry',
|
YARN_GLOBAL_FOLDER: '/tmp/renovate/cache/berry',
|
||||||
|
@ -77,11 +78,16 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
it('only skips build if skipInstalls is false', async () => {
|
it('only skips build if skipInstalls is false', async () => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: '3.0.0',
|
stdout: '3.0.0',
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockResolvedValueOnce('package-lock-contents');
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: '3.0.0',
|
yarn: '3.0.0',
|
||||||
|
@ -95,11 +101,16 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not use global cache if zero install is detected', async () => {
|
it('does not use global cache if zero install is detected', async () => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: '2.1.0',
|
stdout: '2.1.0',
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockResolvedValueOnce('package-lock-contents');
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: '>= 2.0.0',
|
yarn: '>= 2.0.0',
|
||||||
|
@ -119,18 +130,16 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
])(
|
])(
|
||||||
'performs lock file updates using yarn v%s',
|
'performs lock file updates using yarn v%s',
|
||||||
async (yarnVersion, yarnCompatibility) => {
|
async (yarnVersion, yarnCompatibility) => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: yarnVersion,
|
stdout: yarnVersion,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
|
||||||
if (filename.endsWith('.yarnrc')) {
|
|
||||||
return new Promise<string>((resolve) => resolve(null));
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('package-lock-contents')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: yarnCompatibility,
|
yarn: yarnCompatibility,
|
||||||
|
@ -151,15 +160,16 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
it.each([['1.22.0']])(
|
it.each([['1.22.0']])(
|
||||||
'performs lock file updates and full install using yarn v%s',
|
'performs lock file updates and full install using yarn v%s',
|
||||||
async (yarnVersion) => {
|
async (yarnVersion) => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: yarnVersion,
|
stdout: yarnVersion,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile
|
|
||||||
.mockResolvedValueOnce(
|
|
||||||
'yarn-offline-mirror ./npm-packages-offline-cache'
|
|
||||||
)
|
|
||||||
.mockResolvedValueOnce('package-lock-contents');
|
|
||||||
const res = await yarnHelper.generateLockFile('some-dir', {}, {}, [
|
const res = await yarnHelper.generateLockFile('some-dir', {}, {}, [
|
||||||
{
|
{
|
||||||
depName: 'some-dep',
|
depName: 'some-dep',
|
||||||
|
@ -178,18 +188,17 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
])(
|
])(
|
||||||
'performs lock file maintenance using yarn v%s',
|
'performs lock file maintenance using yarn v%s',
|
||||||
async (yarnVersion, yarnCompatibility, expectedFsCalls) => {
|
async (yarnVersion, yarnCompatibility, expectedFsCalls) => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'.yarnrc': null,
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: yarnVersion,
|
stdout: yarnVersion,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
|
||||||
if (filename.endsWith('.yarnrc')) {
|
|
||||||
return new Promise<string>((resolve) => resolve(null));
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('package-lock-contents')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: yarnCompatibility,
|
yarn: yarnCompatibility,
|
||||||
|
@ -201,7 +210,7 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
]);
|
]);
|
||||||
expect(fs.readFile).toHaveBeenCalledTimes(expectedFsCalls);
|
expect(fs.readFile).toHaveBeenCalledTimes(expectedFsCalls);
|
||||||
expect(fs.remove).toHaveBeenCalledTimes(1);
|
expect(fs.remove).toHaveBeenCalledTimes(1);
|
||||||
expect(res.lockFile).toBe('package-lock-contents');
|
expect(res.lockFile).toBeUndefined();
|
||||||
expect(fixSnapshots(execSnapshots)).toMatchSnapshot();
|
expect(fixSnapshots(execSnapshots)).toMatchSnapshot();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -212,18 +221,16 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
])(
|
])(
|
||||||
'performs yarn binary update using yarn v%s',
|
'performs yarn binary update using yarn v%s',
|
||||||
async (yarnVersion, yarnCompatibility) => {
|
async (yarnVersion, yarnCompatibility) => {
|
||||||
|
Fixtures.mock(
|
||||||
|
{
|
||||||
|
'yarn.lock': 'package-lock-contents',
|
||||||
|
},
|
||||||
|
'some-dir'
|
||||||
|
);
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: yarnVersion,
|
stdout: yarnVersion,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
});
|
});
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
|
||||||
if (filename.endsWith('.yarnrc')) {
|
|
||||||
return new Promise<string>((resolve) => resolve(null));
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('package-lock-contents')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const config = {
|
const config = {
|
||||||
constraints: {
|
constraints: {
|
||||||
yarn: yarnCompatibility,
|
yarn: yarnCompatibility,
|
||||||
|
@ -242,13 +249,11 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
it('catches errors', async () => {
|
it('catches errors', async () => {
|
||||||
|
Fixtures.mock({});
|
||||||
const execSnapshots = mockExecAll(exec, {
|
const execSnapshots = mockExecAll(exec, {
|
||||||
stdout: '1.9.4',
|
stdout: '1.9.4',
|
||||||
stderr: 'some-error',
|
stderr: 'some-error',
|
||||||
});
|
});
|
||||||
fs.readFile.mockResolvedValueOnce(null).mockRejectedValueOnce(() => {
|
|
||||||
throw new Error('not-found');
|
|
||||||
});
|
|
||||||
const res = await yarnHelper.generateLockFile('some-dir', {});
|
const res = await yarnHelper.generateLockFile('some-dir', {});
|
||||||
expect(fs.readFile).toHaveBeenCalledTimes(2);
|
expect(fs.readFile).toHaveBeenCalledTimes(2);
|
||||||
expect(res.error).toBeTrue();
|
expect(res.error).toBeTrue();
|
||||||
|
@ -258,69 +263,47 @@ describe('manager/npm/post-update/yarn', () => {
|
||||||
|
|
||||||
describe('checkYarnrc()', () => {
|
describe('checkYarnrc()', () => {
|
||||||
it('returns offline mirror and yarn path', async () => {
|
it('returns offline mirror and yarn path', async () => {
|
||||||
fs.exists.mockImplementation((path) => {
|
Fixtures.mock(
|
||||||
if (path === './.yarn/cli.js') {
|
{
|
||||||
return new Promise<boolean>((resolve) => resolve(true));
|
'.yarn/cli.js': '',
|
||||||
}
|
'/tmp/renovate/.yarnrc':
|
||||||
return new Promise<boolean>((resolve) => resolve(false));
|
'yarn-offline-mirror "./packages-cache"\nyarn-path "/.yarn/cli.js"\n',
|
||||||
});
|
},
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
'/'
|
||||||
if (filename.endsWith('.yarnrc')) {
|
);
|
||||||
return new Promise<string>((resolve) =>
|
expect(await yarnHelper.checkYarnrc('/tmp/renovate')).toEqual({
|
||||||
resolve(
|
|
||||||
'yarn-offline-mirror "./packages-cache"\nyarn-path "./.yarn/cli.js"\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) => resolve(''));
|
|
||||||
});
|
|
||||||
expect(await _yarnHelper.checkYarnrc('/tmp/renovate')).toEqual({
|
|
||||||
offlineMirror: true,
|
offlineMirror: true,
|
||||||
yarnPath: './.yarn/cli.js',
|
yarnPath: '/.yarn/cli.js',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns no offline mirror and unquoted yarn path', async () => {
|
it('returns no offline mirror and unquoted yarn path', async () => {
|
||||||
fs.exists.mockImplementation((path) => {
|
Fixtures.mock(
|
||||||
if (path === './.yarn/cli.js') {
|
{
|
||||||
return new Promise<boolean>((resolve) => resolve(true));
|
'.yarn/cli.js': '',
|
||||||
}
|
'/tmp/renovate/.yarnrc': 'yarn-path /.yarn/cli.js\n',
|
||||||
return new Promise<boolean>((resolve) => resolve(false));
|
},
|
||||||
});
|
'/'
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
);
|
||||||
if (filename.endsWith('.yarnrc')) {
|
expect(await yarnHelper.checkYarnrc('/tmp/renovate')).toEqual({
|
||||||
return new Promise<string>((resolve) =>
|
|
||||||
resolve('yarn-path ./.yarn/cli.js\n')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) => resolve(''));
|
|
||||||
});
|
|
||||||
expect(await _yarnHelper.checkYarnrc('/tmp/renovate')).toEqual({
|
|
||||||
offlineMirror: false,
|
offlineMirror: false,
|
||||||
yarnPath: './.yarn/cli.js',
|
yarnPath: '/.yarn/cli.js',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns offline mirror and no yarn path for non-existant yarn-path binary', async () => {
|
it('returns offline mirror and no yarn path for non-existant yarn-path binary', async () => {
|
||||||
let yarnrcContents = 'yarn-path ./.yarn/cli.js\n';
|
Fixtures.mock(
|
||||||
fs.writeFile.mockImplementation((filename, fileContents) => {
|
{
|
||||||
if (filename.endsWith('.yarnrc')) {
|
'.yarnrc': 'yarn-path ./.yarn/cli.js\n',
|
||||||
yarnrcContents = fileContents;
|
},
|
||||||
}
|
'/tmp/renovate'
|
||||||
return new Promise<void>((resolve) => resolve());
|
);
|
||||||
});
|
const { offlineMirror, yarnPath } = await yarnHelper.checkYarnrc(
|
||||||
fs.readFile.mockImplementation((filename, encoding) => {
|
|
||||||
if (filename.endsWith('.yarnrc')) {
|
|
||||||
return new Promise<string>((resolve) => resolve(yarnrcContents));
|
|
||||||
}
|
|
||||||
return new Promise<string>((resolve) => resolve(''));
|
|
||||||
});
|
|
||||||
const { offlineMirror, yarnPath } = await _yarnHelper.checkYarnrc(
|
|
||||||
'/tmp/renovate'
|
'/tmp/renovate'
|
||||||
);
|
);
|
||||||
expect(offlineMirror).toBeFalse();
|
expect(offlineMirror).toBeFalse();
|
||||||
expect(yarnPath).toBeNull();
|
expect(yarnPath).toBeNull();
|
||||||
expect(yarnrcContents).not.toContain('yarn-path');
|
expect(Fixtures.toJSON()['/tmp/renovate/.yarnrc']).toBe('\n');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { loadFixture } from '../../../../../test/util';
|
import { Fixtures } from '../../../../../test/fixtures';
|
||||||
import * as npmUpdater from '.';
|
import * as npmUpdater from '.';
|
||||||
|
|
||||||
const readFixture = (x: string): string => loadFixture(x, '../..');
|
const readFixture = (x: string): string => Fixtures.get(x, '../..');
|
||||||
|
|
||||||
const input01Content = readFixture('inputs/01.json');
|
const input01Content = readFixture('inputs/01.json');
|
||||||
const input01GlobContent = readFixture('inputs/01-glob.json');
|
const input01GlobContent = readFixture('inputs/01-glob.json');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import type { ExtractConfig } from '../types';
|
import type { ExtractConfig } from '../types';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ const config: ExtractConfig = {};
|
||||||
describe('manager/pip_setup/extract', () => {
|
describe('manager/pip_setup/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns found deps', () => {
|
it('returns found deps', () => {
|
||||||
const content = loadFixture(packageFile);
|
const content = Fixtures.get(packageFile);
|
||||||
|
|
||||||
expect(extractPackageFile(content, packageFile, config)).toMatchSnapshot({
|
expect(extractPackageFile(content, packageFile, config)).toMatchSnapshot({
|
||||||
deps: [
|
deps: [
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const brokenYaml = loadFixture('update.yaml');
|
|
||||||
const packageFile = loadFixture('extract.yaml');
|
|
||||||
|
|
||||||
describe('manager/pub/extract', () => {
|
describe('manager/pub/extract', () => {
|
||||||
describe('extractPackageFile', () => {
|
describe('extractPackageFile', () => {
|
||||||
it('should return null if package does not contain any deps', () => {
|
it('should return null if package does not contain any deps', () => {
|
||||||
|
@ -11,11 +8,17 @@ describe('manager/pub/extract', () => {
|
||||||
expect(res).toBeNull();
|
expect(res).toBeNull();
|
||||||
});
|
});
|
||||||
it('should return null if package is invalid', () => {
|
it('should return null if package is invalid', () => {
|
||||||
const res = extractPackageFile(brokenYaml, 'pubspec.yaml');
|
const res = extractPackageFile(
|
||||||
|
Fixtures.get('update.yaml'),
|
||||||
|
'pubspec.yaml'
|
||||||
|
);
|
||||||
expect(res).toBeNull();
|
expect(res).toBeNull();
|
||||||
});
|
});
|
||||||
it('should return valid dependencies', () => {
|
it('should return valid dependencies', () => {
|
||||||
const res = extractPackageFile(packageFile, 'pubspec.yaml');
|
const res = extractPackageFile(
|
||||||
|
Fixtures.get('extract.yaml'),
|
||||||
|
'pubspec.yaml'
|
||||||
|
);
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
datasource: 'dart',
|
datasource: 'dart',
|
||||||
deps: [
|
deps: [
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from './../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const sbt = loadFixture(`sample.sbt`);
|
const sbt = Fixtures.get(`sample.sbt`);
|
||||||
const sbtScalaVersionVariable = loadFixture(`scala-version-variable.sbt`);
|
const sbtScalaVersionVariable = Fixtures.get(`scala-version-variable.sbt`);
|
||||||
const sbtMissingScalaVersion = loadFixture(`missing-scala-version.sbt`);
|
const sbtMissingScalaVersion = Fixtures.get(`missing-scala-version.sbt`);
|
||||||
const sbtDependencyFile = loadFixture(`dependency-file.scala`);
|
const sbtDependencyFile = Fixtures.get(`dependency-file.scala`);
|
||||||
const sbtPrivateVariableDependencyFile = loadFixture(
|
const sbtPrivateVariableDependencyFile = Fixtures.get(
|
||||||
`private-variable-dependency-file.scala`
|
`private-variable-dependency-file.scala`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const content = loadFixture('setup-cfg-1.txt');
|
|
||||||
|
|
||||||
describe('manager/setup-cfg/extract', () => {
|
describe('manager/setup-cfg/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts dependencies', () => {
|
it('extracts dependencies', () => {
|
||||||
const res = extractPackageFile(content);
|
const res = extractPackageFile(Fixtures.get('setup-cfg-1.txt'));
|
||||||
expect(res).toMatchSnapshot({
|
expect(res).toMatchSnapshot({
|
||||||
deps: [
|
deps: [
|
||||||
{ depName: 'qux', currentValue: '>=4.4.4' },
|
{ depName: 'qux', currentValue: '>=4.4.4' },
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const pkgContent = loadFixture(`SamplePackage.swift`);
|
|
||||||
|
|
||||||
describe('manager/swift/index', () => {
|
describe('manager/swift/index', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty content', () => {
|
it('returns null for empty content', () => {
|
||||||
|
@ -129,7 +127,9 @@ describe('manager/swift/index', () => {
|
||||||
).toMatchSnapshot({ deps: [{ currentValue: '..<"1.2.3"' }] });
|
).toMatchSnapshot({ deps: [{ currentValue: '..<"1.2.3"' }] });
|
||||||
});
|
});
|
||||||
it('parses multiple packages', () => {
|
it('parses multiple packages', () => {
|
||||||
expect(extractPackageFile(pkgContent)).toMatchSnapshot();
|
expect(
|
||||||
|
extractPackageFile(Fixtures.get(`SamplePackage.swift`))
|
||||||
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
import { createReadStream } from 'fs';
|
import { createReadStream } from 'fs';
|
||||||
import { DirectoryResult, dir } from 'tmp-promise';
|
import { DirectoryResult, dir } from 'tmp-promise';
|
||||||
|
import { Fixtures } from '../../../../test/fixtures';
|
||||||
import * as httpMock from '../../../../test/http-mock';
|
import * as httpMock from '../../../../test/http-mock';
|
||||||
import { getFixturePath, loadFixture, logger } from '../../../../test/util';
|
import { getFixturePath, logger } from '../../../../test/util';
|
||||||
import { GlobalConfig } from '../../../config/global';
|
import { GlobalConfig } from '../../../config/global';
|
||||||
import { TerraformProviderDatasource } from '../../../datasource/terraform-provider';
|
import { TerraformProviderDatasource } from '../../../datasource/terraform-provider';
|
||||||
import { Logger } from '../../../logger/types';
|
import { Logger } from '../../../logger/types';
|
||||||
import { TerraformProviderHash } from './hash';
|
import { TerraformProviderHash } from './hash';
|
||||||
|
|
||||||
const releaseBackendUrl = TerraformProviderDatasource.defaultRegistryUrls[1];
|
const releaseBackendUrl = TerraformProviderDatasource.defaultRegistryUrls[1];
|
||||||
const releaseBackendAzurerm = loadFixture('releaseBackendAzurerm_2_56_0.json');
|
const releaseBackendAzurerm = Fixtures.get('releaseBackendAzurerm_2_56_0.json');
|
||||||
|
|
||||||
const log = logger.logger as jest.Mocked<Logger>;
|
const log = logger.logger as jest.Mocked<Logger>;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { loadFixture } from '../../../../test/util';
|
import { Fixtures } from '../../../../test/fixtures';
|
||||||
import { extractLocks } from './util';
|
import { extractLocks } from './util';
|
||||||
|
|
||||||
const validLockfile = loadFixture('validLockfile.hcl');
|
|
||||||
|
|
||||||
describe('manager/terraform/lockfile/util', () => {
|
describe('manager/terraform/lockfile/util', () => {
|
||||||
describe('extractLocks()', () => {
|
describe('extractLocks()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
|
@ -11,7 +9,7 @@ describe('manager/terraform/lockfile/util', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts', () => {
|
it('extracts', () => {
|
||||||
const res = extractLocks(validLockfile);
|
const res = extractLocks(Fixtures.get('validLockfile.hcl'));
|
||||||
expect(res).toHaveLength(3);
|
expect(res).toHaveLength(3);
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const tg1 = loadFixture('2.hcl');
|
|
||||||
const tg2 = `terragrunt {
|
|
||||||
source = "../../modules/fe"
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
describe('manager/terragrunt/extract', () => {
|
describe('manager/terragrunt/extract', () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('returns null for empty', () => {
|
it('returns null for empty', () => {
|
||||||
expect(extractPackageFile('nothing here')).toBeNull();
|
expect(extractPackageFile('nothing here')).toBeNull();
|
||||||
});
|
});
|
||||||
it('extracts terragrunt sources', () => {
|
it('extracts terragrunt sources', () => {
|
||||||
const res = extractPackageFile(tg1);
|
const res = extractPackageFile(Fixtures.get('2.hcl'));
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(30);
|
expect(res.deps).toHaveLength(30);
|
||||||
expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(5);
|
expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(5);
|
||||||
});
|
});
|
||||||
it('returns null if only local terragrunt deps', () => {
|
it('returns null if only local terragrunt deps', () => {
|
||||||
expect(extractPackageFile(tg2)).toBeNull();
|
expect(
|
||||||
|
extractPackageFile(`terragrunt {
|
||||||
|
source = "../../modules/fe"
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { smartTruncate } from './pr-body';
|
import { smartTruncate } from './pr-body';
|
||||||
|
|
||||||
const prBody = loadFixture('pr-body.txt');
|
const prBody = Fixtures.get('pr-body.txt');
|
||||||
|
|
||||||
describe('platform/utils/pr-body', () => {
|
describe('platform/utils/pr-body', () => {
|
||||||
describe('.smartTruncate', () => {
|
describe('.smartTruncate', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { readOnlyIssueBody } from './read-only-issue-body';
|
import { readOnlyIssueBody } from './read-only-issue-body';
|
||||||
|
|
||||||
const issueBody = loadFixture('issue-body.txt');
|
const issueBody = Fixtures.get('issue-body.txt');
|
||||||
|
|
||||||
describe('platform/utils/read-only-issue-body', () => {
|
describe('platform/utils/read-only-issue-body', () => {
|
||||||
describe('.readOnlyIssueBody', () => {
|
describe('.readOnlyIssueBody', () => {
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
import fs from 'fs-extra';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { remove } from './proxies';
|
import { exists, readFile, remove } from './proxies';
|
||||||
|
|
||||||
jest.mock('fs-extra');
|
jest.mock('fs-extra', () => Fixtures.fsExtra());
|
||||||
|
|
||||||
describe('util/fs/proxies', () => {
|
describe('util/fs/proxies', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
Fixtures.reset();
|
||||||
|
});
|
||||||
|
|
||||||
describe('remove', () => {
|
describe('remove', () => {
|
||||||
it('should call remove in fs-extra', async () => {
|
it('should call remove in fs-extra', async () => {
|
||||||
(fs.remove as jest.Mock).mockResolvedValue(undefined);
|
Fixtures.mock(
|
||||||
const path = 'path mock';
|
{
|
||||||
expect(await remove(path)).toBeUndefined();
|
test: 'test',
|
||||||
expect(fs.remove).toHaveBeenNthCalledWith(1, path);
|
},
|
||||||
|
'/'
|
||||||
|
);
|
||||||
|
expect(await readFile('/test', 'utf8')).toBe('test');
|
||||||
|
await remove('/test');
|
||||||
|
expect(await exists('/test')).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import mockFs from 'mock-fs';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
import { loadFixture } from '../../../test/util';
|
|
||||||
import { configFileNames } from '../../config/app-strings';
|
import { configFileNames } from '../../config/app-strings';
|
||||||
import { GlobalConfig } from '../../config/global';
|
import { GlobalConfig } from '../../config/global';
|
||||||
import { EditorConfig } from './editor-config';
|
import { EditorConfig } from './editor-config';
|
||||||
import { IndentationType } from './indentation-type';
|
import { IndentationType } from './indentation-type';
|
||||||
|
|
||||||
|
jest.mock('fs');
|
||||||
const defaultConfigFile = configFileNames[0];
|
const defaultConfigFile = configFileNames[0];
|
||||||
|
|
||||||
const GLOBAL_EDITOR_CONFIG = loadFixture('.global_editorconfig', '.');
|
|
||||||
const JSON_FILES_EDITOR_CONFIG = loadFixture('.json_editorconfig', '.');
|
|
||||||
const NON_JSON_FILES_EDITOR_CONFIG = loadFixture('.non_json_editorconfig', '.');
|
|
||||||
|
|
||||||
describe('util/json-writer/editor-config', () => {
|
describe('util/json-writer/editor-config', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
GlobalConfig.set({
|
GlobalConfig.set({
|
||||||
|
@ -18,13 +14,13 @@ describe('util/json-writer/editor-config', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
beforeEach(() => {
|
||||||
mockFs.restore();
|
Fixtures.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle empty .editorconfig file', async () => {
|
it('should handle empty .editorconfig file', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
mockFs({
|
Fixtures.mock({
|
||||||
'.editorconfig': '',
|
'.editorconfig': '',
|
||||||
});
|
});
|
||||||
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
||||||
|
@ -35,8 +31,8 @@ describe('util/json-writer/editor-config', () => {
|
||||||
|
|
||||||
it('should handle global config from .editorconfig', async () => {
|
it('should handle global config from .editorconfig', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
mockFs({
|
Fixtures.mock({
|
||||||
'.editorconfig': GLOBAL_EDITOR_CONFIG,
|
'.editorconfig': Fixtures.get('.global_editorconfig'),
|
||||||
});
|
});
|
||||||
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
||||||
expect(format.indentationSize).toBe(6);
|
expect(format.indentationSize).toBe(6);
|
||||||
|
@ -45,8 +41,8 @@ describe('util/json-writer/editor-config', () => {
|
||||||
|
|
||||||
it('should not handle non json config from .editorconfig', async () => {
|
it('should not handle non json config from .editorconfig', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
mockFs({
|
Fixtures.mock({
|
||||||
'.editorconfig': NON_JSON_FILES_EDITOR_CONFIG,
|
'.editorconfig': Fixtures.get('.non_json_editorconfig'),
|
||||||
});
|
});
|
||||||
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
||||||
|
|
||||||
|
@ -56,8 +52,8 @@ describe('util/json-writer/editor-config', () => {
|
||||||
|
|
||||||
it('should handle json config from .editorconfig', async () => {
|
it('should handle json config from .editorconfig', async () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
mockFs({
|
Fixtures.mock({
|
||||||
'.editorconfig': JSON_FILES_EDITOR_CONFIG,
|
'.editorconfig': Fixtures.get('.json_editorconfig'),
|
||||||
});
|
});
|
||||||
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
const format = await EditorConfig.getCodeFormat(defaultConfigFile);
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,33 @@
|
||||||
import { defaultConfig, loadFixture } from '../../../test/util';
|
import { Fixtures } from '../../../test/fixtures';
|
||||||
|
import { defaultConfig } from '../../../test/util';
|
||||||
|
import { GlobalConfig } from '../../config/global';
|
||||||
import { WORKER_FILE_UPDATE_FAILED } from '../../constants/error-messages';
|
import { WORKER_FILE_UPDATE_FAILED } from '../../constants/error-messages';
|
||||||
import { extractPackageFile } from '../../manager/html';
|
import { extractPackageFile } from '../../manager/html';
|
||||||
import type { BranchUpgradeConfig } from '../types';
|
import type { BranchUpgradeConfig } from '../types';
|
||||||
import { doAutoReplace } from './auto-replace';
|
import { doAutoReplace } from './auto-replace';
|
||||||
|
|
||||||
const sampleHtml = loadFixture('sample.html', `../../manager/html`);
|
const sampleHtml = Fixtures.get('sample.html', `../../manager/html`);
|
||||||
|
|
||||||
jest.mock('../../util/fs');
|
jest.mock('fs-extra', () => Fixtures.fsExtra());
|
||||||
|
|
||||||
describe('workers/branch/auto-replace', () => {
|
describe('workers/branch/auto-replace', () => {
|
||||||
describe('doAutoReplace', () => {
|
describe('doAutoReplace', () => {
|
||||||
let reuseExistingBranch: boolean;
|
let reuseExistingBranch: boolean;
|
||||||
let upgrade: BranchUpgradeConfig;
|
let upgrade: BranchUpgradeConfig;
|
||||||
|
beforeAll(() => {
|
||||||
|
GlobalConfig.set({
|
||||||
|
localDir: '/temp',
|
||||||
|
});
|
||||||
|
});
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
upgrade = {
|
upgrade = {
|
||||||
...JSON.parse(JSON.stringify(defaultConfig)),
|
...JSON.parse(JSON.stringify(defaultConfig)),
|
||||||
manager: 'html',
|
manager: 'html',
|
||||||
|
packageFile: 'test',
|
||||||
};
|
};
|
||||||
reuseExistingBranch = false;
|
reuseExistingBranch = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rebases if the deps list has changed', async () => {
|
it('rebases if the deps list has changed', async () => {
|
||||||
upgrade.baseDeps = extractPackageFile(sampleHtml).deps;
|
upgrade.baseDeps = extractPackageFile(sampleHtml).deps;
|
||||||
reuseExistingBranch = true;
|
reuseExistingBranch = true;
|
||||||
|
|
|
@ -187,6 +187,7 @@ export async function doAutoReplace(
|
||||||
newString
|
newString
|
||||||
);
|
);
|
||||||
await writeLocalFile(upgrade.packageFile, testContent);
|
await writeLocalFile(upgrade.packageFile, testContent);
|
||||||
|
|
||||||
if (await confirmIfDepUpdated(upgrade, testContent)) {
|
if (await confirmIfDepUpdated(upgrade, testContent)) {
|
||||||
return testContent;
|
return testContent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,7 @@
|
||||||
"@types/auth-header": "1.0.2",
|
"@types/auth-header": "1.0.2",
|
||||||
"@types/bunyan": "1.8.8",
|
"@types/bunyan": "1.8.8",
|
||||||
"@types/cacache": "15.0.1",
|
"@types/cacache": "15.0.1",
|
||||||
|
"@types/callsite": "1.0.31",
|
||||||
"@types/changelog-filename-regex": "2.0.0",
|
"@types/changelog-filename-regex": "2.0.0",
|
||||||
"@types/clean-git-ref": "2.0.0",
|
"@types/clean-git-ref": "2.0.0",
|
||||||
"@types/conventional-commits-detector": "1.0.0",
|
"@types/conventional-commits-detector": "1.0.0",
|
||||||
|
@ -253,6 +254,7 @@
|
||||||
"@typescript-eslint/eslint-plugin": "5.9.1",
|
"@typescript-eslint/eslint-plugin": "5.9.1",
|
||||||
"@typescript-eslint/parser": "5.9.1",
|
"@typescript-eslint/parser": "5.9.1",
|
||||||
"aws-sdk-client-mock": "0.5.6",
|
"aws-sdk-client-mock": "0.5.6",
|
||||||
|
"callsite": "1.0.0",
|
||||||
"conventional-changelog-conventionalcommits": "4.6.3",
|
"conventional-changelog-conventionalcommits": "4.6.3",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"diff": "5.0.0",
|
"diff": "5.0.0",
|
||||||
|
@ -275,6 +277,7 @@
|
||||||
"jest-mock-extended": "2.0.4",
|
"jest-mock-extended": "2.0.4",
|
||||||
"jest-silent-reporter": "0.5.0",
|
"jest-silent-reporter": "0.5.0",
|
||||||
"markdownlint-cli2": "0.4.0",
|
"markdownlint-cli2": "0.4.0",
|
||||||
|
"memfs": "3.3.0",
|
||||||
"mock-fs": "5.1.2",
|
"mock-fs": "5.1.2",
|
||||||
"mockdate": "3.0.5",
|
"mockdate": "3.0.5",
|
||||||
"nock": "13.2.2",
|
"nock": "13.2.2",
|
||||||
|
|
101
test/fixtures.ts
Normal file
101
test/fixtures.ts
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
import type fs from 'fs';
|
||||||
|
import type { PathLike } from 'fs';
|
||||||
|
import callsite from 'callsite';
|
||||||
|
import { DirectoryJSON, fs as memfs, vol } from 'memfs';
|
||||||
|
import upath from 'upath';
|
||||||
|
|
||||||
|
const realFs = jest.requireActual<typeof fs>('fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to work with in-memory file-system
|
||||||
|
*/
|
||||||
|
export class Fixtures {
|
||||||
|
/**
|
||||||
|
* Returns content from fixture file from __fixtures__ folder
|
||||||
|
* @param name name of the fixture file
|
||||||
|
* @param [fixturesRoot] - Where to find the fixtures, uses the current test folder by default
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
static get(name: string, fixturesRoot = '.'): string {
|
||||||
|
return realFs.readFileSync(
|
||||||
|
upath.resolve(Fixtures.getPathToFixtures(fixturesRoot), name),
|
||||||
|
{
|
||||||
|
encoding: 'utf-8',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds files from a flat json object to the file-system
|
||||||
|
* @param json flat object
|
||||||
|
* @param cwd is an optional string used to compute absolute file paths, if a file path is given in a relative form
|
||||||
|
*/
|
||||||
|
static mock(json: DirectoryJSON, cwd?: string): void {
|
||||||
|
vol.fromJSON(json, cwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports the whole contents of the volume recursively to a flat JSON object
|
||||||
|
* @param paths is an optional argument that specifies one or more paths to be exported. If this argument is omitted, the whole volume is exported. paths can be an array of paths. A path can be a string, Buffer or an URL object.
|
||||||
|
* @param json is an optional object parameter which will be populated with the exported files
|
||||||
|
* @param isRelative is boolean that specifies if returned paths should be relative
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
static toJSON(
|
||||||
|
paths?: PathLike | PathLike[],
|
||||||
|
json?: Record<string, unknown>,
|
||||||
|
isRelative?: boolean
|
||||||
|
): DirectoryJSON {
|
||||||
|
return vol.toJSON(paths, json, isRelative);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all files from the volume.
|
||||||
|
*/
|
||||||
|
static reset(): void {
|
||||||
|
vol.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporary solution, when all tests will be rewritten to Fixtures mocks can be moved into __mocks__ folder
|
||||||
|
static fsExtra(): any {
|
||||||
|
return {
|
||||||
|
...memfs,
|
||||||
|
pathExists: jest.fn().mockImplementation(pathExists),
|
||||||
|
remove: jest.fn().mockImplementation(memfs.promises.rm),
|
||||||
|
readFile: jest.fn().mockImplementation(memfs.promises.readFile),
|
||||||
|
writeFile: jest.fn().mockImplementation(memfs.promises.writeFile),
|
||||||
|
outputFile: jest.fn().mockImplementation(outputFile),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getPathToFixtures(fixturesRoot = '.'): string {
|
||||||
|
const stack = callsite();
|
||||||
|
const callerDir = upath.dirname(stack[2].getFileName());
|
||||||
|
return upath.resolve(callerDir, fixturesRoot, '__fixtures__');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function outputFile(
|
||||||
|
file: string,
|
||||||
|
data: string | Buffer | Uint8Array
|
||||||
|
): Promise<void> {
|
||||||
|
const dir = upath.dirname(file);
|
||||||
|
|
||||||
|
if (await pathExists(dir)) {
|
||||||
|
await memfs.promises.writeFile(file, data);
|
||||||
|
} else {
|
||||||
|
await memfs.promises.mkdir(dir, {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
await memfs.promises.writeFile(file, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pathExists(path: string): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await memfs.promises.access(path);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
22
yarn.lock
22
yarn.lock
|
@ -2204,6 +2204,11 @@
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
"@types/responselike" "*"
|
"@types/responselike" "*"
|
||||||
|
|
||||||
|
"@types/callsite@1.0.31":
|
||||||
|
version "1.0.31"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/callsite/-/callsite-1.0.31.tgz#55cfc887088d67f0310fcb20bd9100bb7146d2fc"
|
||||||
|
integrity sha512-jrKmIHhuZVGUpOR1s4TgY9BTt/Eh9CFCjHVZ2FsrKmHSo3J/vpl6EpK08SfMLrX2IY1ZEFA+BPRTJQGg4xIHsA==
|
||||||
|
|
||||||
"@types/changelog-filename-regex@2.0.0":
|
"@types/changelog-filename-regex@2.0.0":
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/changelog-filename-regex/-/changelog-filename-regex-2.0.0.tgz#b5af0ee9b36106f593dfd6ac6b6514ec166c4ef2"
|
resolved "https://registry.yarnpkg.com/@types/changelog-filename-regex/-/changelog-filename-regex-2.0.0.tgz#b5af0ee9b36106f593dfd6ac6b6514ec166c4ef2"
|
||||||
|
@ -3300,6 +3305,11 @@ call-bind@^1.0.0, call-bind@^1.0.2:
|
||||||
function-bind "^1.1.1"
|
function-bind "^1.1.1"
|
||||||
get-intrinsic "^1.0.2"
|
get-intrinsic "^1.0.2"
|
||||||
|
|
||||||
|
callsite@1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
|
||||||
|
integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA=
|
||||||
|
|
||||||
callsites@^3.0.0:
|
callsites@^3.0.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
|
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
|
||||||
|
@ -4704,6 +4714,11 @@ fs-minipass@^2.0.0, fs-minipass@^2.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
minipass "^3.0.0"
|
minipass "^3.0.0"
|
||||||
|
|
||||||
|
fs-monkey@1.0.3:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3"
|
||||||
|
integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==
|
||||||
|
|
||||||
fs.realpath@^1.0.0:
|
fs.realpath@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||||
|
@ -6701,6 +6716,13 @@ mdurl@^1.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
|
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
|
||||||
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
|
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
|
||||||
|
|
||||||
|
memfs@3.3.0:
|
||||||
|
version "3.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.3.0.tgz#4da2d1fc40a04b170a56622c7164c6be2c4cbef2"
|
||||||
|
integrity sha512-BEE62uMfKOavX3iG7GYX43QJ+hAeeWnwIAuJ/R6q96jaMtiLzhsxHJC8B1L7fK7Pt/vXDRwb3SG/yBpNGDPqzg==
|
||||||
|
dependencies:
|
||||||
|
fs-monkey "1.0.3"
|
||||||
|
|
||||||
memorystream@^0.3.1:
|
memorystream@^0.3.1:
|
||||||
version "0.3.1"
|
version "0.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
|
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
|
||||||
|
|
Loading…
Reference in a new issue