diff --git a/__tests__/cache.test.ts b/__tests__/cache.test.ts index 9762fb98..df7a59bd 100644 --- a/__tests__/cache.test.ts +++ b/__tests__/cache.test.ts @@ -17,6 +17,7 @@ describe('dependency cache', () => { let spyWarning: jest.SpyInstance>; let spyDebug: jest.SpyInstance>; let spySaveState: jest.SpyInstance>; + let spyCoreError: jest.SpyInstance; beforeEach(() => { workspace = mkdtempSync(join(tmpdir(), 'setup-java-cache-')); @@ -51,6 +52,10 @@ describe('dependency cache', () => { spySaveState = jest.spyOn(core, 'saveState'); spySaveState.mockImplementation(() => null); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { @@ -58,6 +63,10 @@ describe('dependency cache', () => { process.env['GITHUB_WORKSPACE'] = ORIGINAL_GITHUB_WORKSPACE; process.env['RUNNER_OS'] = ORIGINAL_RUNNER_OS; resetState(); + + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); }); describe('restore', () => { diff --git a/__tests__/cleanup-java.test.ts b/__tests__/cleanup-java.test.ts index 375a2ad1..4cd2709d 100644 --- a/__tests__/cleanup-java.test.ts +++ b/__tests__/cleanup-java.test.ts @@ -11,19 +11,32 @@ describe('cleanup', () => { Parameters >; let spyJobStatusSuccess: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyWarning = jest.spyOn(core, 'warning'); spyWarning.mockImplementation(() => null); + spyInfo = jest.spyOn(core, 'info'); spyInfo.mockImplementation(() => null); + spyCacheSave = jest.spyOn(cache, 'saveCache'); + spyJobStatusSuccess = jest.spyOn(util, 'isJobStatusSuccess'); spyJobStatusSuccess.mockReturnValue(true); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); + createStateForSuccessfulRestore(); }); + afterEach(() => { resetState(); + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); }); it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => { diff --git a/__tests__/distributors/adopt-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts index 0b35c3d3..d24940ff 100644 --- a/__tests__/distributors/adopt-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -9,9 +9,11 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models'; import os from 'os'; import manifestData from '../data/adopt.json'; +import * as core from '@actions/core'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -20,6 +22,10 @@ describe('getAvailableVersions', () => { headers: {}, result: [] }); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index befa2d25..3905c711 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -248,6 +248,7 @@ describe('setupJava', () => { let spyCoreExportVariable: jest.SpyInstance; let spyCoreAddPath: jest.SpyInstance; let spyCoreSetOutput: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath'); @@ -287,6 +288,10 @@ describe('setupJava', () => { spyCoreSetOutput = jest.spyOn(core, 'setOutput'); spyCoreSetOutput.mockImplementation(() => undefined); + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => undefined); + jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType); }); diff --git a/__tests__/distributors/corretto-installer.test.ts b/__tests__/distributors/corretto-installer.test.ts index 1da5e393..4234f4e4 100644 --- a/__tests__/distributors/corretto-installer.test.ts +++ b/__tests__/distributors/corretto-installer.test.ts @@ -4,13 +4,14 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models'; import {CorrettoDistribution} from '../../src/distributions/corretto/installer'; import * as util from '../../src/util'; import os from 'os'; -import {isGeneratorFunction} from 'util/types'; +import * as core from '@actions/core'; import manifestData from '../data/corretto.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -23,6 +24,10 @@ describe('getAvailableVersions', () => { util, 'getDownloadArchiveExtension' ); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/dragonwell-installer.test.ts b/__tests__/distributors/dragonwell-installer.test.ts index e33c7479..de6564ed 100644 --- a/__tests__/distributors/dragonwell-installer.test.ts +++ b/__tests__/distributors/dragonwell-installer.test.ts @@ -1,12 +1,14 @@ import {HttpClient} from '@actions/http-client'; import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer'; import * as utils from '../../src/util'; +import * as core from '@actions/core'; import manifestData from '../data/dragonwell.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -21,6 +23,10 @@ describe('getAvailableVersions', () => { 'getDownloadArchiveExtension' ); spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz'); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/graalvm-installer.test.ts b/__tests__/distributors/graalvm-installer.test.ts index 95f553e3..bd12d3b4 100644 --- a/__tests__/distributors/graalvm-installer.test.ts +++ b/__tests__/distributors/graalvm-installer.test.ts @@ -42,6 +42,7 @@ beforeAll(() => { describe('GraalVMDistribution', () => { let distribution: GraalVMDistribution; let mockHttpClient: jest.Mocked; + 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(() => { diff --git a/__tests__/distributors/jetbrains-installer.test.ts b/__tests__/distributors/jetbrains-installer.test.ts index 44d8ef89..e75a76db 100644 --- a/__tests__/distributors/jetbrains-installer.test.ts +++ b/__tests__/distributors/jetbrains-installer.test.ts @@ -4,9 +4,11 @@ import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer import manifestData from '../data/jetbrains.json'; import os from 'os'; +import * as core from '@actions/core'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -15,6 +17,10 @@ describe('getAvailableVersions', () => { headers: {}, result: [] }); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/liberica-installer.test.ts b/__tests__/distributors/liberica-installer.test.ts index 1787de7c..dbf7f43d 100644 --- a/__tests__/distributors/liberica-installer.test.ts +++ b/__tests__/distributors/liberica-installer.test.ts @@ -5,11 +5,13 @@ import { } from '../../src/distributions/liberica/models'; import {HttpClient} from '@actions/http-client'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/liberica.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -18,6 +20,10 @@ describe('getAvailableVersions', () => { headers: {}, result: manifestData as LibericaVersion[] }); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/liberica-linux-installer.test.ts b/__tests__/distributors/liberica-linux-installer.test.ts index 28b64055..74f014b3 100644 --- a/__tests__/distributors/liberica-linux-installer.test.ts +++ b/__tests__/distributors/liberica-linux-installer.test.ts @@ -5,11 +5,13 @@ import { } from '../../src/distributions/liberica/models'; import {HttpClient} from '@actions/http-client'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/liberica-linux.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -18,6 +20,10 @@ describe('getAvailableVersions', () => { headers: {}, result: manifestData as LibericaVersion[] }); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/liberica-windows-installer.test.ts b/__tests__/distributors/liberica-windows-installer.test.ts index de59b4d2..0d6c12f4 100644 --- a/__tests__/distributors/liberica-windows-installer.test.ts +++ b/__tests__/distributors/liberica-windows-installer.test.ts @@ -5,11 +5,13 @@ import { } from '../../src/distributions/liberica/models'; import {HttpClient} from '@actions/http-client'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/liberica-windows.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -18,6 +20,9 @@ describe('getAvailableVersions', () => { headers: {}, result: manifestData as LibericaVersion[] }); + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts index 8e9d5d43..201d1d25 100644 --- a/__tests__/distributors/local-installer.test.ts +++ b/__tests__/distributors/local-installer.test.ts @@ -27,6 +27,7 @@ describe('setupJava', () => { let spyFsReadDir: jest.SpyInstance; let spyUtilsExtractJdkFile: jest.SpyInstance; let spyPathResolve: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; const expectedJdkFile = 'JavaLocalJdkFile'; beforeEach(() => { @@ -93,6 +94,10 @@ describe('setupJava', () => { // Spy on path methods spyPathResolve = jest.spyOn(path, 'resolve'); spyPathResolve.mockImplementation((path: string) => path); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/microsoft-installer.test.ts b/__tests__/distributors/microsoft-installer.test.ts index 16c43637..bac9d425 100644 --- a/__tests__/distributors/microsoft-installer.test.ts +++ b/__tests__/distributors/microsoft-installer.test.ts @@ -8,6 +8,7 @@ describe('findPackageForDownload', () => { let distribution: MicrosoftDistributions; let spyGetManifestFromRepo: jest.SpyInstance; let spyDebug: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { distribution = new MicrosoftDistributions({ @@ -26,6 +27,10 @@ describe('findPackageForDownload', () => { spyDebug = jest.spyOn(core, 'debug'); spyDebug.mockImplementation(() => {}); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); it.each([ diff --git a/__tests__/distributors/oracle-installer.test.ts b/__tests__/distributors/oracle-installer.test.ts index 226eca90..6f64058c 100644 --- a/__tests__/distributors/oracle-installer.test.ts +++ b/__tests__/distributors/oracle-installer.test.ts @@ -8,6 +8,7 @@ describe('findPackageForDownload', () => { let distribution: OracleDistribution; let spyDebug: jest.SpyInstance; let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { distribution = new OracleDistribution({ @@ -19,6 +20,10 @@ describe('findPackageForDownload', () => { spyDebug = jest.spyOn(core, 'debug'); spyDebug.mockImplementation(() => {}); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); it.each([ diff --git a/__tests__/distributors/sapmachine-installer.test.ts b/__tests__/distributors/sapmachine-installer.test.ts index 9367cb7f..e2f19746 100644 --- a/__tests__/distributors/sapmachine-installer.test.ts +++ b/__tests__/distributors/sapmachine-installer.test.ts @@ -1,12 +1,14 @@ import {HttpClient} from '@actions/http-client'; import {SapMachineDistribution} from '../../src/distributions/sapmachine/installer'; import * as utils from '../../src/util'; +import * as core from '@actions/core'; import manifestData from '../data/sapmachine.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -21,6 +23,10 @@ describe('getAvailableVersions', () => { 'getDownloadArchiveExtension' ); spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz'); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/semeru-installer.test.ts b/__tests__/distributors/semeru-installer.test.ts index 690478f7..61e618c2 100644 --- a/__tests__/distributors/semeru-installer.test.ts +++ b/__tests__/distributors/semeru-installer.test.ts @@ -4,9 +4,11 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models'; import {SemeruDistribution} from '../../src/distributions/semeru/installer'; import manifestData from '../data/semeru.json'; +import * as core from '@actions/core'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -15,6 +17,9 @@ describe('getAvailableVersions', () => { headers: {}, result: [] }); + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/temurin-installer.test.ts b/__tests__/distributors/temurin-installer.test.ts index f540901e..5810c881 100644 --- a/__tests__/distributors/temurin-installer.test.ts +++ b/__tests__/distributors/temurin-installer.test.ts @@ -7,9 +7,11 @@ import { import {JavaInstallerOptions} from '../../src/distributions/base-models'; import manifestData from '../data/temurin.json'; +import * as core from '@actions/core'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -18,6 +20,9 @@ describe('getAvailableVersions', () => { headers: {}, result: [] }); + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts index d2fbfdc9..1372d0e4 100644 --- a/__tests__/distributors/zulu-installer.test.ts +++ b/__tests__/distributors/zulu-installer.test.ts @@ -3,12 +3,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer'; import {IZuluVersions} from '../../src/distributions/zulu/models'; import * as utils from '../../src/util'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/zulu-releases-default.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -23,6 +25,10 @@ describe('getAvailableVersions', () => { 'getDownloadArchiveExtension' ); spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz'); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/zulu-linux-installer.test.ts b/__tests__/distributors/zulu-linux-installer.test.ts index fd81e4e8..a37da36e 100644 --- a/__tests__/distributors/zulu-linux-installer.test.ts +++ b/__tests__/distributors/zulu-linux-installer.test.ts @@ -4,12 +4,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer'; import {IZuluVersions} from '../../src/distributions/zulu/models'; import * as utils from '../../src/util'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/zulu-linux.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -24,6 +26,10 @@ describe('getAvailableVersions', () => { 'getDownloadArchiveExtension' ); spyUtilGetDownloadArchiveExtension.mockReturnValue('zip'); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => { diff --git a/__tests__/distributors/zulu-windows-installer.test.ts b/__tests__/distributors/zulu-windows-installer.test.ts index 2ca5830b..c70c1a78 100644 --- a/__tests__/distributors/zulu-windows-installer.test.ts +++ b/__tests__/distributors/zulu-windows-installer.test.ts @@ -4,12 +4,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer'; import {IZuluVersions} from '../../src/distributions/zulu/models'; import * as utils from '../../src/util'; import os from 'os'; +import * as core from '@actions/core'; import manifestData from '../data/zulu-windows.json'; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + let spyCoreError: jest.SpyInstance; beforeEach(() => { spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); @@ -24,6 +26,10 @@ describe('getAvailableVersions', () => { 'getDownloadArchiveExtension' ); spyUtilGetDownloadArchiveExtension.mockReturnValue('zip'); + + // Mock core.error to suppress error logs + spyCoreError = jest.spyOn(core, 'error'); + spyCoreError.mockImplementation(() => {}); }); afterEach(() => {