mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-01-22 13:27:45 -05:00
Refine platform handling in tests.
This commit is contained in:
@@ -81,7 +81,7 @@ And(~'^offline mode is enabled with unreachable internet$') { ->
|
||||
And(~'^a machine with "(.*)" installed$') { String platform ->
|
||||
def binFolder = "$sdkmanBaseDir/bin" as File
|
||||
UnameStub.prepareIn(binFolder)
|
||||
.forPlatform(asSdkmanPlatform(platform, null))
|
||||
.forPlatform(asSdkmanPlatform(platform))
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') {
|
||||
}
|
||||
|
||||
And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primeUniversalHookFor("pre", candidate, version, lcPlatform)
|
||||
primeUniversalHookFor("post", candidate, version, lcPlatform)
|
||||
}
|
||||
|
||||
And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primePlatformSpecificHookFor("pre", candidate, version, lcPlatform)
|
||||
primePlatformSpecificHookFor("post", candidate, version, lcPlatform)
|
||||
}
|
||||
@@ -44,23 +44,23 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$'
|
||||
}
|
||||
|
||||
And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "valid")
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, lcPlatform)
|
||||
}
|
||||
|
||||
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" that returns successfully$/) { String phase, String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess())
|
||||
}
|
||||
|
||||
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure())
|
||||
}
|
||||
|
||||
And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, null).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "invalid")
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ class UnixUtils {
|
||||
asSdkmanPlatform(System.getProperty("os.name"), System.getProperty("os.arch"))
|
||||
}
|
||||
|
||||
static asSdkmanPlatform(platform, architecture) {
|
||||
if("aarch64" == architecture) {
|
||||
platform += architecture
|
||||
}
|
||||
static asSdkmanPlatform(platform, architecture = "") {
|
||||
|
||||
def platformArch = architecture == "aarch64" ? "$platform $architecture" : platform
|
||||
|
||||
def result
|
||||
switch (platform) {
|
||||
switch (platformArch) {
|
||||
case "Mac OS X":
|
||||
result = "Darwin"
|
||||
break
|
||||
@@ -25,7 +24,7 @@ class UnixUtils {
|
||||
case "Linux 32":
|
||||
result = "Linux32"
|
||||
break
|
||||
case "Linuxaarch64":
|
||||
case "Linux aarch64":
|
||||
result = "LinuxARM64"
|
||||
break
|
||||
case "FreeBSD":
|
||||
|
||||
Reference in New Issue
Block a user