mirror of
https://github.com/actions/setup-java.git
synced 2026-07-31 16:12:59 +00:00
Deprecate legacy Adopt distributions in v5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0cd196f2-1044-4d33-96bb-8e794a00b03c
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import * as core from '@actions/core';
|
||||
import {
|
||||
AdoptDistribution,
|
||||
AdoptImplementation
|
||||
} from '../../src/distributions/adopt/installer';
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import {getJavaDistribution} from '../../src/distributions/distribution-factory';
|
||||
|
||||
describe('getJavaDistribution', () => {
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['adopt', AdoptImplementation.Hotspot, 'temurin'],
|
||||
['adopt-hotspot', AdoptImplementation.Hotspot, 'temurin'],
|
||||
['adopt-openj9', AdoptImplementation.OpenJ9, 'semeru']
|
||||
])(
|
||||
'warns that %s is deprecated while preserving its installer',
|
||||
(
|
||||
distributionName: string,
|
||||
implementation: AdoptImplementation,
|
||||
replacement: string
|
||||
) => {
|
||||
const warningSpy = jest
|
||||
.spyOn(core, 'warning')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
const distribution = getJavaDistribution(
|
||||
distributionName,
|
||||
installerOptions
|
||||
);
|
||||
|
||||
expect(distribution).toBeInstanceOf(AdoptDistribution);
|
||||
if (!(distribution instanceof AdoptDistribution)) {
|
||||
throw new Error(`Expected an Adopt installer for ${distributionName}`);
|
||||
}
|
||||
expect(distribution['jvmImpl']).toBe(implementation);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
`The '${distributionName}' legacy AdoptOpenJDK distribution is deprecated and will be removed in setup-java v6. Please migrate to the '${replacement}' distribution.`
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user