-
Notifications
You must be signed in to change notification settings - Fork 834
Refactor error handling and improve test logging for installers #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d78498f
97169f0
96e5c4f
102c209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ beforeAll(() => { | |
| describe('GraalVMDistribution', () => { | ||
| let distribution: GraalVMDistribution; | ||
| let mockHttpClient: jest.Mocked<http.HttpClient>; | ||
| let spyCoreError: jest.SpyInstance; | ||
|
|
||
| const defaultOptions: JavaInstallerOptions = { | ||
| version: '17', | ||
|
|
@@ -59,6 +60,10 @@ describe('GraalVMDistribution', () => { | |
| (distribution as any).http = mockHttpClient; | ||
|
|
||
| (util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz'); | ||
|
|
||
| // Mock core.error to suppress error logs | ||
| spyCoreError = jest.spyOn(core, 'error'); | ||
| spyCoreError.mockImplementation(() => {}); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
|
|
@@ -348,11 +353,17 @@ describe('GraalVMDistribution', () => { | |
| } as http.HttpClientResponse; | ||
| mockHttpClient.head.mockResolvedValue(mockResponse); | ||
|
|
||
| // Verify the error is thrown with the expected message | ||
| await expect( | ||
| (distribution as any).findPackageForDownload('17.0.99') | ||
| ).rejects.toThrow( | ||
| 'Could not find GraalVM for SemVer 17.0.99. Please check if this version is available at https://download.oracle.com/graalvm' | ||
| "Could not find satisfied version for SemVer '17.0.99'" | ||
| ); | ||
|
|
||
| // Verify the hint about checking the base URL is included | ||
| await expect( | ||
| (distribution as any).findPackageForDownload('17.0.99') | ||
| ).rejects.toThrow('https://download.oracle.com/graalvm'); | ||
| }); | ||
|
|
||
| it('should throw error for unauthorized access (401)', async () => { | ||
|
|
@@ -496,12 +507,11 @@ describe('GraalVMDistribution', () => { | |
|
|
||
| await expect( | ||
| (distribution as any).findPackageForDownload('23') | ||
| ).rejects.toThrow("Unable to find latest version for '23-ea'"); | ||
|
|
||
| // Verify error logging | ||
| expect(core.error).toHaveBeenCalledWith( | ||
| 'Available versions: 23-ea-20240716' | ||
| ).rejects.toThrow( | ||
| "No EA build is marked as 'latest' for version range '23-ea'. Available EA versions: 23-ea-20240716." | ||
| ); | ||
|
|
||
| // Verify error logging - removed as we now use the helper method which doesn't call core.error | ||
| }); | ||
|
|
||
| it('should throw error when no matching file for architecture in EA build', async () => { | ||
|
|
@@ -708,11 +718,11 @@ describe('GraalVMDistribution', () => { | |
|
|
||
| await expect( | ||
| (distribution as any).findEABuildDownloadUrl('23-ea') | ||
| ).rejects.toThrow("Unable to find latest version for '23-ea'"); | ||
|
|
||
| expect(core.error).toHaveBeenCalledWith( | ||
| 'Available versions: 23-ea-20240716, 23-ea-20240709' | ||
| ).rejects.toThrow( | ||
| "No EA build is marked as 'latest' for version range '23-ea'. Available EA versions: 23-ea-20240716, 23-ea-20240709." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is hard to read. If there's a range, you should use some range notification markers, e.g. |
||
| ); | ||
|
|
||
| // Verify error logging - removed as we now use the helper method which doesn't call core.error | ||
| }); | ||
|
|
||
| it('should throw error when no matching file for architecture', async () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, this message is lousy.
satisfiedisn't compatible withcould not find.You could say
could not satisfyorcould not find a satisfying, but the text here doesn't work.