mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 06:51:11 +00:00
c908d078ef
* fix(datasource): replace getJsonUnchecked with validated getJson in npm/Node/PyPI/Go Replace all getJsonUnchecked calls in npm, Node.js, PyPI, and Go datasources with Zod-validated getJson calls: - datasource/npm: add NpmResponseSchema to schema.ts (shared with presets) - config/presets/npm: migrate to NpmResponseSchema with passthrough version fields - datasource/node-version: add NodeReleasesSchema using LooseArray - datasource/pypi: add PypiJSONSchema (nullable+catch for lenient empty-body handling) - datasource/go: add VersionInfoSchema for both versionInfo and getLatestVersion calls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * some manual cleaning up * removing schema level catch * removing some more types * refactor: rename schema * fix linter errors * remove schema suffix which hasn't been catched by linter --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { NodeRelease, NodeReleases } from './schema.ts';
|
|
|
|
describe('modules/datasource/node-version/schema', () => {
|
|
describe('NodeRelease', () => {
|
|
it('parses a stable LTS release', () => {
|
|
const result = NodeRelease.parse({
|
|
version: 'v20.0.0',
|
|
date: '2023-04-18',
|
|
lts: 'Iron',
|
|
});
|
|
expect(result.version).toBe('v20.0.0');
|
|
expect(result.lts).toBe('Iron');
|
|
});
|
|
|
|
it('parses a non-LTS release', () => {
|
|
const result = NodeRelease.parse({
|
|
version: 'v21.0.0',
|
|
date: '2023-10-17',
|
|
lts: false,
|
|
});
|
|
expect(result.version).toBe('v21.0.0');
|
|
expect(result.lts).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('NodeReleasesSchema', () => {
|
|
it('parses an array of releases, skipping invalid elements', () => {
|
|
const input = [
|
|
{ version: 'v20.0.0', date: '2023-04-18', lts: 'Iron' },
|
|
{ notARelease: true }, // invalid — missing required fields
|
|
{ version: 'v18.0.0', date: '2022-04-19', lts: 'Hydrogen' },
|
|
];
|
|
const result = NodeReleases.parse(input);
|
|
// invalid element is skipped (LooseArray behavior)
|
|
expect(result).toHaveLength(2);
|
|
expect(result[0].version).toBe('v20.0.0');
|
|
expect(result[1].version).toBe('v18.0.0');
|
|
});
|
|
});
|
|
});
|