0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/ocb/update.spec.ts
Sebastian Poxhofer b14661fd0c
feat(managers/ocb): add new manager for OpenTelemetryCollectorBuilder (#26509)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2024-01-08 15:59:20 +00:00

78 lines
2.2 KiB
TypeScript

import { codeBlock } from 'common-tags';
import { bumpPackageVersion } from '.';
describe('modules/manager/ocb/update', () => {
describe('bumpPackageVersion()', () => {
it('increments with all fields', () => {
const content = codeBlock`
dist:
name: otelcol-custom
description: Local OpenTelemetry Collector binary
module: github.com/open-telemetry/opentelemetry-collector
otelcol_version: 0.40.0
version: 1.0.0
output_path: /tmp/dist
`;
const expected = content.replace('1.0.0', '1.0.1');
const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch');
expect(bumpedContent).toEqual(expected);
});
it('increments with double quotes', () => {
const content = codeBlock`
dist:
version: "1.0.0"
`;
const expected = content.replace('1.0.0', '1.0.1');
const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch');
expect(bumpedContent).toEqual(expected);
});
it('increments with single quotes', () => {
const content = codeBlock`
dist:
version: '1.0.0'
`;
const expected = content.replace('1.0.0', '1.0.1');
const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch');
expect(bumpedContent).toEqual(expected);
});
it('no ops', () => {
const content = codeBlock`
dist:
version: '0.0.2'
`;
const { bumpedContent } = bumpPackageVersion(content, '0.0.1', 'patch');
expect(bumpedContent).toEqual(content);
});
it('updates', () => {
const content = codeBlock`
dist:
version: '0.0.2'
`;
const { bumpedContent } = bumpPackageVersion(content, '0.0.1', 'minor');
const expected = content.replace('0.0.2', '0.1.0');
expect(bumpedContent).toEqual(expected);
});
it('returns content if bumping errors', () => {
const content = codeBlock`
dist:
version: '1.0.0'
`;
const { bumpedContent } = bumpPackageVersion(
content,
'0.0.2',
// @ts-expect-error supplying a wrong parameter to trigger an exception
true,
);
expect(bumpedContent).toEqual(content);
});
});
});