mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Add unit test
This commit is contained in:
parent
0a93947425
commit
d88ee5c3dc
3 changed files with 21 additions and 2 deletions
|
@ -241,3 +241,22 @@ describe('getAvailableVersions', () => {
|
|||
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
|
||||
};
|
||||
});
|
||||
|
||||
describe('convertVersionToSemver', () => {
|
||||
it.each([
|
||||
['12', '12'],
|
||||
['12.0', '12.0'],
|
||||
['12.0.2', '12.0.2'],
|
||||
['12.0.2+1', '12.0.2+1'],
|
||||
['12.0.2.1.0', '12.0.2+1.0']
|
||||
])('%s -> %s', (input: string, expected: string) => {
|
||||
const distribution = new CorrettoDistribution({
|
||||
version: '12',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const actual = distribution['convertVersionToSemver'](input);
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
|
2
dist/setup/index.js
vendored
2
dist/setup/index.js
vendored
|
@ -104298,10 +104298,10 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
|
|||
return match[1];
|
||||
}
|
||||
convertVersionToSemver(version) {
|
||||
// corretto uses 5 digit semver-like notation e.g. 17.0.6.10.1
|
||||
const versionArray = version.split('.');
|
||||
const mainVersion = versionArray.slice(0, 3).join('.');
|
||||
if (versionArray.length > 3) {
|
||||
// intentionally ignore more than 4 numbers because it is invalid semver
|
||||
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
|
||||
}
|
||||
return mainVersion;
|
||||
|
|
|
@ -181,10 +181,10 @@ export class CorrettoDistribution extends JavaBase {
|
|||
}
|
||||
|
||||
private convertVersionToSemver(version: string) {
|
||||
// corretto uses 5 digit semver-like notation e.g. 17.0.6.10.1
|
||||
const versionArray = version.split('.');
|
||||
const mainVersion = versionArray.slice(0, 3).join('.');
|
||||
if (versionArray.length > 3) {
|
||||
// intentionally ignore more than 4 numbers because it is invalid semver
|
||||
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue