mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
0e6429b13e
* refactor(types): document `localDir` isn't a `globalOnly` option To make sure that it's clear when reviewing `GlobalConfig`, as well as working with our types, we can move the `localDir` definition into a separate type. * fixup! refactor(types): document `localDir` isn't a `globalOnly` option * fixup! refactor(types): document `localDir` isn't a `globalOnly` option Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fixup! refactor(types): document `localDir` isn't a `globalOnly` option Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fixup! refactor(types): document `localDir` isn't a `globalOnly` option Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> --------- Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
167 lines
4.8 KiB
TypeScript
167 lines
4.8 KiB
TypeScript
import { codeBlock } from 'common-tags';
|
|
import { Fixtures } from '~test/fixtures.ts';
|
|
import { fs } from '~test/util.ts';
|
|
import { GlobalConfig } from '../../../config/global.ts';
|
|
import type {
|
|
InternalGlobalConfigOptions,
|
|
RepoGlobalConfig,
|
|
} from '../../../config/types.ts';
|
|
import { GlasskubePackagesDatasource } from '../../datasource/glasskube-packages/index.ts';
|
|
import type { ExtractConfig } from '../types.ts';
|
|
import { extractAllPackageFiles, extractPackageFile } from './extract.ts';
|
|
|
|
const config: ExtractConfig = {};
|
|
const adminConfig: RepoGlobalConfig & InternalGlobalConfigOptions = {
|
|
localDir: '',
|
|
};
|
|
|
|
const packageWithRepoName = codeBlock`
|
|
apiVersion: packages.glasskube.dev/v1alpha1
|
|
kind: ClusterPackage
|
|
metadata:
|
|
name: argo-cd
|
|
spec:
|
|
packageInfo:
|
|
name: argo-cd
|
|
repositoryName: glasskube
|
|
version: v2.11.7+1
|
|
`;
|
|
const repository = codeBlock`
|
|
apiVersion: packages.glasskube.dev/v1alpha1
|
|
kind: PackageRepository
|
|
metadata:
|
|
annotations:
|
|
packages.glasskube.dev/default-repository: "true"
|
|
name: glasskube
|
|
spec:
|
|
url: https://packages.dl.glasskube.dev/packages
|
|
`;
|
|
|
|
vi.mock('../../../util/fs/index.ts');
|
|
|
|
describe('modules/manager/glasskube/extract', () => {
|
|
beforeEach(() => {
|
|
GlobalConfig.set(adminConfig);
|
|
});
|
|
|
|
describe('extractPackageFile()', () => {
|
|
it('should extract version and registryUrl', () => {
|
|
const deps = extractPackageFile(
|
|
Fixtures.get('package-and-repo.yaml'),
|
|
'package-and-repo.yaml',
|
|
);
|
|
expect(deps).toEqual({
|
|
deps: [
|
|
{
|
|
depName: 'argo-cd',
|
|
currentValue: 'v2.11.7+1',
|
|
datasource: GlasskubePackagesDatasource.id,
|
|
registryUrls: ['https://packages.dl.glasskube.dev/packages'],
|
|
},
|
|
],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('extractAllPackageFiles()', () => {
|
|
it('should return null for empty packageFiles', async () => {
|
|
const deps = await extractAllPackageFiles(config, []);
|
|
expect(deps).toBeNull();
|
|
});
|
|
|
|
it('should skip package with non-existing repo', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(packageWithRepoName);
|
|
const deps = await extractAllPackageFiles(config, ['package.yaml']);
|
|
expect(deps).toEqual([
|
|
{
|
|
packageFile: 'package.yaml',
|
|
deps: [
|
|
{
|
|
depName: 'argo-cd',
|
|
currentValue: 'v2.11.7+1',
|
|
datasource: GlasskubePackagesDatasource.id,
|
|
skipReason: 'unknown-registry',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should extract registryUrl from repo in other file', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(packageWithRepoName);
|
|
fs.readLocalFile.mockResolvedValueOnce(repository);
|
|
const deps = await extractAllPackageFiles(config, [
|
|
'package.yaml',
|
|
'repo.yaml',
|
|
]);
|
|
expect(deps).toEqual([
|
|
{
|
|
packageFile: 'package.yaml',
|
|
deps: [
|
|
{
|
|
depName: 'argo-cd',
|
|
currentValue: 'v2.11.7+1',
|
|
datasource: GlasskubePackagesDatasource.id,
|
|
registryUrls: ['https://packages.dl.glasskube.dev/packages'],
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('should extract registryUrl from default repo in other file', async () => {
|
|
fs.readLocalFile.mockResolvedValueOnce(codeBlock`
|
|
apiVersion: packages.glasskube.dev/v1alpha1
|
|
kind: ClusterPackage
|
|
metadata:
|
|
name: argo-cd
|
|
spec:
|
|
packageInfo:
|
|
name: argo-cd
|
|
version: v2.11.7+1
|
|
repositoryName: ""
|
|
`);
|
|
fs.readLocalFile.mockResolvedValueOnce(codeBlock`
|
|
apiVersion: packages.glasskube.dev/v1alpha1
|
|
kind: ClusterPackage
|
|
metadata:
|
|
name: argo-cd
|
|
spec:
|
|
packageInfo:
|
|
name: argo-cd
|
|
version: v2.11.7+1
|
|
`);
|
|
fs.readLocalFile.mockResolvedValueOnce(repository);
|
|
const deps = await extractAllPackageFiles(config, [
|
|
'package-with-empty-reponame.yaml',
|
|
'package-with-missing-reponame.yaml',
|
|
'repo.yaml',
|
|
]);
|
|
expect(deps).toEqual([
|
|
{
|
|
packageFile: 'package-with-empty-reponame.yaml',
|
|
deps: [
|
|
{
|
|
depName: 'argo-cd',
|
|
currentValue: 'v2.11.7+1',
|
|
datasource: GlasskubePackagesDatasource.id,
|
|
registryUrls: ['https://packages.dl.glasskube.dev/packages'],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
packageFile: 'package-with-missing-reponame.yaml',
|
|
deps: [
|
|
{
|
|
depName: 'argo-cd',
|
|
currentValue: 'v2.11.7+1',
|
|
datasource: GlasskubePackagesDatasource.id,
|
|
registryUrls: ['https://packages.dl.glasskube.dev/packages'],
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
});
|