Skip to content

Commit

Permalink
test(datasource/custom): test yaml format
Browse files Browse the repository at this point in the history
  • Loading branch information
nSimonFR committed Nov 10, 2023
1 parent b4b42ef commit d727ba5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,21 @@ export type UpdateConfig<
export type RenovateRepository =
| string
| {
repository: string;
secrets?: Record<string, string>;
};
repository: string;
secrets?: Record<string, string>;
};

export type UseBaseBranchConfigType = 'merge' | 'none';
export type ConstraintsFilter = 'strict' | 'none';

// TODO: Proper typings
export interface RenovateConfig
extends LegacyAdminConfig,
RenovateSharedConfig,
UpdateConfig<PackageRule>,
AssigneesAndReviewersConfig,
ConfigMigration,
Record<string, unknown> {
RenovateSharedConfig,
UpdateConfig<PackageRule>,
AssigneesAndReviewersConfig,
ConfigMigration,
Record<string, unknown> {
depName?: string;
baseBranches?: string[];
useBaseBranchConfig?: UseBaseBranchConfigType;
Expand Down Expand Up @@ -270,8 +270,8 @@ export interface CustomDatasourceConfig {

export interface AllConfig
extends RenovateConfig,
GlobalOnlyConfig,
RepoGlobalConfig { }
GlobalOnlyConfig,
RepoGlobalConfig {}

export interface AssigneesAndReviewersConfig {
assigneesFromCodeOwners?: boolean;
Expand Down Expand Up @@ -313,8 +313,8 @@ export type MergeStrategy =
// TODO: Proper typings
export interface PackageRule
extends RenovateSharedConfig,
UpdateConfig,
Record<string, unknown> {
UpdateConfig,
Record<string, unknown> {
description?: string | string[];
isVulnerabilityAlert?: boolean;
matchFileNames?: string[];
Expand Down Expand Up @@ -379,11 +379,11 @@ export interface RenovateOptionBase {
name: string;

parent?:
| 'customDatasources'
| 'hostRules'
| 'packageRules'
| 'postUpgradeTasks'
| 'customManagers';
| 'customDatasources'
| 'hostRules'
| 'packageRules'
| 'postUpgradeTasks'
| 'customManagers';

stage?: RenovateConfigStage;

Expand Down
41 changes: 41 additions & 0 deletions lib/modules/datasource/custom/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it } from '@jest/globals';
import expect from 'expect';
import { getPkgReleases } from '..';
import * as httpMock from '../../../../test/http-mock';
import { CustomDatasource } from './index';
Expand Down Expand Up @@ -198,6 +200,45 @@ describe('index', () => {
expect(result).toBeNull();
});

it('return releases for yaml API directly exposing in Renovate format', async () => {
const expected = {
releases: [
{
version: '1.0.0',
},
{
version: '2.0.0',
},
{
version: '3.0.0',
},
],
};

const yaml = `releases:\n - version: 1.0.0\n - version: 2.0.0\n - version: 3.0.0`;

httpMock
.scope('https://example.com')
.get('/v1')
.reply(200, yaml, {
'Content-Type': 'text/yaml',
});

const result = await getPkgReleases({
datasource: `${CustomDatasource.id}.foo`,
packageName: 'myPackage',
customDatasources: {
foo: {
defaultRegistryUrlTemplate: 'https://example.com/v1',
format: 'yaml',
},
},
});

expect(result).toEqual(expected);
});


it('return release when templating registryUrl', async () => {
const expected = {
releases: [
Expand Down

0 comments on commit d727ba5

Please sign in to comment.