From d2ec614519bde38f96f3cd068b7aeba7b13e1912 Mon Sep 17 00:00:00 2001 From: Brian Cristante <33549821+brcrista@users.noreply.github.com> Date: Wed, 8 Dec 2021 13:30:55 -0500 Subject: [PATCH] Fix test --- dist/setup/index.js | 6 +++--- src/distributions/microsoft/installer.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 3d7a838e..855880b7 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -13926,8 +13926,8 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { return jdkVersions; }); } - getPlatformOption() { - switch (process.platform) { + getPlatformOption(platform = process.platform /* for testing */) { + switch (platform) { case 'darwin': return { archive: 'tar.gz', os: 'macos' }; case 'win32': @@ -13935,7 +13935,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { case 'linux': return { archive: 'tar.gz', os: 'linux' }; default: - throw new Error(`Platform '${process.platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'`); + throw new Error(`Platform '${platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'`); } } convertVersionToSemver(version) { diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 5376cb29..79fffe5e 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -89,8 +89,10 @@ export class MicrosoftDistributions extends JavaBase { return jdkVersions; } - private getPlatformOption(): PlatformOptions { - switch (process.platform) { + private getPlatformOption( + platform: NodeJS.Platform = process.platform /* for testing */ + ): PlatformOptions { + switch (platform) { case 'darwin': return { archive: 'tar.gz', os: 'macos' }; case 'win32': @@ -99,7 +101,7 @@ export class MicrosoftDistributions extends JavaBase { return { archive: 'tar.gz', os: 'linux' }; default: throw new Error( - `Platform '${process.platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'` + `Platform '${platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'` ); } }