microsoft test file update and tool-version test file

This commit is contained in:
mahabaleshwars 2024-02-20 17:28:38 +05:30
parent ba9976ce09
commit 7e99af0127
6 changed files with 64 additions and 6 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

1
.github/.tool-versions vendored Normal file
View File

@ -0,0 +1 @@
java jdk17.0.7

View File

@ -288,6 +288,7 @@ jobs:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'microsoft', 'corretto']
java-version-file-array: [.java-version, .tool-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
@ -300,7 +301,7 @@ jobs:
with:
distribution: ${{ matrix.distribution }}
java-version: 11
java-version-file: '.java-version'
java-version-file: './${{ matrix.java-version-file-array }}'
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash
@ -313,6 +314,7 @@ jobs:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
java-version-file-array: [.java-version, .tool-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
@ -324,7 +326,7 @@ jobs:
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: '.java-version'
java-version-file: './${{ matrix.java-version-file-array }}'
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash
@ -337,6 +339,7 @@ jobs:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'adopt-openj9', 'zulu']
java-version-file-array: [.java-version, .tool-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
@ -348,7 +351,7 @@ jobs:
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: '.java-version'
java-version-file: './${{ matrix.java-version-file-array }}'
- name: Verify Java
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
shell: bash
@ -361,6 +364,7 @@ jobs:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
java-version-file-array: [.java-version, .tool-versions]
steps:
- name: Checkout
uses: actions/checkout@v4
@ -372,7 +376,7 @@ jobs:
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: '.java-version'
java-version-file: './${{ matrix.java-version-file-array }}'
- name: Verify Java
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
shell: bash

View File

@ -70,6 +70,12 @@
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.7-windows-aarch64.zip",
"arch": "aarch64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip"
}
]
},

View File

@ -89,6 +89,30 @@ describe('findPackageForDownload', () => {
expect(result.url).toBe(url);
});
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('darwin');
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-${distroArch}.tar.gz`;
expect(result.url).toBe(expectedUrl);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
@ -108,11 +132,35 @@ describe('findPackageForDownload', () => {
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-${distroArch}.tar.gz`;
expect(result.url).toBe(expectedUrl);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('win32');
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-${distroArch}.zip`;
expect(result.url).toBe(expectedUrl);
}
);
it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */

View File

@ -57,5 +57,4 @@
"url": "https://github.com/actions/setup-java/issues"
},
"homepage": "https://github.com/actions/setup-java#readme"
}