mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 17:51:49 +00:00
03baf6ee4a
* test(noNewURL): add new rule enforcing parseUrl() from 'lib/util/url.ts' * replace newURL with parseUrl * remove non-null assertions marks if appropiate * test: add additional tests * test: add additional tests and ignore where it makes sense * implement suggestions * test: further improve coverage * apply suggestion
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
import type { PackageDependency } from '../types.ts';
|
|
import {
|
|
analyseTerragruntModule,
|
|
gitTagsRefMatchRegex,
|
|
githubRefMatchRegex,
|
|
} from './modules.ts';
|
|
import type { TerraformManagerData } from './types.ts';
|
|
|
|
describe('modules/manager/terragrunt/modules', () => {
|
|
describe('githubRefMatchRegex', () => {
|
|
it('should split project and tag from source', () => {
|
|
const groups = githubRefMatchRegex.exec(
|
|
'github.com/hashicorp/example?ref=v1.0.0',
|
|
)?.groups;
|
|
expect(groups).toEqual({
|
|
project: 'hashicorp/example',
|
|
tag: 'v1.0.0',
|
|
});
|
|
});
|
|
|
|
it('should parse alpha-numeric characters as well as dots, underscores, and dashes in repo names', () => {
|
|
const groups = githubRefMatchRegex.exec(
|
|
'github.com/hashicorp/example.repo-123?ref=v1.0.0',
|
|
)?.groups;
|
|
expect(groups).toEqual({
|
|
project: 'hashicorp/example.repo-123',
|
|
tag: 'v1.0.0',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('gitTagsRefMatchRegex', () => {
|
|
it('should split host, path and tag from source', () => {
|
|
const http = gitTagsRefMatchRegex.exec(
|
|
'http://github.com/hashicorp/example?ref=v1.0.0',
|
|
)?.groups;
|
|
const https = gitTagsRefMatchRegex.exec(
|
|
'https://github.com/hashicorp/example?ref=v1.0.0',
|
|
)?.groups;
|
|
const ssh = gitTagsRefMatchRegex.exec(
|
|
'ssh://github.com/hashicorp/example?ref=v1.0.0',
|
|
)?.groups;
|
|
|
|
expect(http).toMatchObject({
|
|
host: 'github.com',
|
|
path: 'hashicorp/example',
|
|
tag: 'v1.0.0',
|
|
});
|
|
expect(https).toMatchObject({
|
|
host: 'github.com',
|
|
path: 'hashicorp/example',
|
|
tag: 'v1.0.0',
|
|
});
|
|
expect(ssh).toMatchObject({
|
|
host: 'github.com',
|
|
path: 'hashicorp/example',
|
|
tag: 'v1.0.0',
|
|
});
|
|
});
|
|
|
|
it('should parse alpha-numeric characters as well as dots, underscores, and dashes in repo names', () => {
|
|
const http = gitTagsRefMatchRegex.exec(
|
|
'http://github.com/hashicorp/example.repo-123?ref=v1.0.0',
|
|
)?.groups;
|
|
const https = gitTagsRefMatchRegex.exec(
|
|
'https://github.com/hashicorp/example.repo-123?ref=v1.0.0',
|
|
)?.groups;
|
|
const ssh = gitTagsRefMatchRegex.exec(
|
|
'ssh://github.com/hashicorp/example.repo-123?ref=v1.0.0',
|
|
)?.groups;
|
|
|
|
expect(http).toMatchObject({
|
|
path: 'hashicorp/example.repo-123',
|
|
tag: 'v1.0.0',
|
|
});
|
|
expect(https).toMatchObject({
|
|
path: 'hashicorp/example.repo-123',
|
|
tag: 'v1.0.0',
|
|
});
|
|
expect(ssh).toMatchObject({
|
|
path: 'hashicorp/example.repo-123',
|
|
tag: 'v1.0.0',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('modules/manager/terragrunt/modules', () => {
|
|
it('sets skipReason for invalid git tags URL', () => {
|
|
const dep: PackageDependency<TerraformManagerData> = {
|
|
managerData: {
|
|
source: 'ssh://[/path?ref=v1.0.0',
|
|
terragruntDependencyType: 'terraform',
|
|
moduleName: 'terragrunt',
|
|
},
|
|
};
|
|
analyseTerragruntModule(dep);
|
|
expect(dep.skipReason).toBe('invalid-url');
|
|
});
|
|
});
|