mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-24 16:42:24 -04:00
Move environment initialisation into own step definition.
This commit is contained in:
@@ -2,6 +2,7 @@ Feature: Broadcast
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: A command is issued with no prior Broadcast received
|
||||
Given no prior Broadcast was received
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Feature: Command Line Interop
|
||||
|
||||
Background:
|
||||
Given an initialised system
|
||||
And the internet is reachable
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Enter gvm
|
||||
When I enter "gvm"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
Feature: Current Candidate
|
||||
|
||||
Background:
|
||||
And the internet is reachable
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Display current candidate version in use
|
||||
Given the candidate "grails" version "1.3.9" is already installed and default
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Flush
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Flush omitting the Qualifier
|
||||
When I enter "gvm flush"
|
||||
|
||||
@@ -4,16 +4,19 @@ Feature: Forced Offline Mode
|
||||
|
||||
Scenario: Enter an invalid offline mode
|
||||
Given offline mode is disabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm offline grails"
|
||||
Then I see "Stop! grails is not a valid offline mode."
|
||||
|
||||
Scenario: Issue Offline command without qualification
|
||||
Given offline mode is disabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm offline"
|
||||
Then I see "Stop! Specify a valid offline mode."
|
||||
|
||||
Scenario: Enable Offline Mode with internet reachable
|
||||
Given offline mode is disabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm offline enable"
|
||||
Then I see "Forced offline mode enabled."
|
||||
And I do not see "OFFLINE MODE ENABLED!"
|
||||
@@ -22,6 +25,7 @@ Feature: Forced Offline Mode
|
||||
|
||||
Scenario: Disable Offline Mode with internet reachable
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm offline disable"
|
||||
Then I see "Online mode re-enabled!"
|
||||
When I enter "gvm install grails 2.1.0" and answer "Y"
|
||||
@@ -30,6 +34,7 @@ Feature: Forced Offline Mode
|
||||
|
||||
Scenario: Disable Offline Mode with internet unreachable
|
||||
Given offline mode is enabled with unreachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm offline disable"
|
||||
Then I see "Online mode re-enabled!"
|
||||
When I enter "gvm install grails 2.1.0"
|
||||
@@ -39,6 +44,7 @@ Feature: Forced Offline Mode
|
||||
#broadcast
|
||||
Scenario: Recall a broadcast while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When a prior Broadcast "This is an OLD Broadcast!" was issued
|
||||
And I enter "gvm broadcast"
|
||||
Then I see "This is an OLD Broadcast!"
|
||||
@@ -46,18 +52,21 @@ Feature: Forced Offline Mode
|
||||
#gvm version
|
||||
Scenario: Determine the GVM version while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm version"
|
||||
Then I see the current gvm version
|
||||
|
||||
#list candidate version
|
||||
Scenario: List candidate versions found while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm list grails"
|
||||
Then I see "Offline Mode: only showing installed grails versions"
|
||||
|
||||
#use version
|
||||
Scenario: Use an uninstalled candidate version while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
And the candidate "grails" version "1.3.9" is already installed and default
|
||||
And the candidate "grails" version "2.1.0" is not installed
|
||||
When I enter "gvm use grails 2.1.0"
|
||||
@@ -66,6 +75,7 @@ Feature: Forced Offline Mode
|
||||
#default version
|
||||
Scenario: Set the default to an uninstalled candidate version while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
And the candidate "grails" version "1.3.9" is already installed and default
|
||||
When I enter "gvm default grails 2.1.0"
|
||||
Then I see "Stop! grails 2.1.0 is not available in offline mode."
|
||||
@@ -73,6 +83,7 @@ Feature: Forced Offline Mode
|
||||
#install command
|
||||
Scenario: Install a candidate version that is not installed while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
And the candidate "grails" version "2.1.0" is not installed
|
||||
When I enter "gvm install grails 2.1.0"
|
||||
Then I see "Stop! grails 2.1.0 is not available in offline mode."
|
||||
@@ -80,6 +91,7 @@ Feature: Forced Offline Mode
|
||||
#uninstall command
|
||||
Scenario: Uninstall a candidate version while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
And the candidate "grails" version "2.1.0" is already installed and default
|
||||
When I enter "gvm uninstall grails 2.1.0"
|
||||
And the candidate "grails" version "2.1.0" is not installed
|
||||
@@ -87,6 +99,7 @@ Feature: Forced Offline Mode
|
||||
#current command
|
||||
Scenario: Display the current version of a candidate while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
And the candidate "grails" version "2.1.0" is already installed and default
|
||||
When I enter "gvm current grails"
|
||||
Then I see "Using grails version 2.1.0"
|
||||
@@ -94,12 +107,14 @@ Feature: Forced Offline Mode
|
||||
#help command
|
||||
Scenario: Request help while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm help"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
|
||||
#selfupdate command
|
||||
Scenario: Attempt self-update while Forced Offline
|
||||
Given offline mode is enabled with reachable internet
|
||||
And an initialised environment
|
||||
When I enter "gvm selfupdate"
|
||||
Then I see "This command is not available in offline mode."
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Feature: Idempotent Self Update
|
||||
|
||||
Scenario: Attempt Self Update on an up to date system
|
||||
Given an initialised system
|
||||
And the internet is reachable
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
When I enter "gvm selfupdate"
|
||||
Then I see "No update available at this time."
|
||||
@@ -2,13 +2,13 @@ Feature: Initialisation
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Use gvm for the first time
|
||||
When I enter "gvm"
|
||||
Then the gvm work folder is created
|
||||
|
||||
Scenario: Use gvm after initialisation
|
||||
Given an initialised system
|
||||
When I enter "gvm"
|
||||
Then I see "Usage: gvm <command> <candidate> [version]"
|
||||
Then the gvm work folder is created
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Install Candidate
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Install a default Candidate
|
||||
Given the default "grails" candidate is "2.1.0"
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: List Candidates
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: List an uninstalled available Version
|
||||
Given I do not have a "grails" candidate installed
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Local Development Versions
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Install a new local development version
|
||||
Given the candidate "groovy" version "2.1-SNAPSHOT" is not available for download
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Mnemonics
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Shortcut for listing an uninstalled available Version
|
||||
Given I do not have a "grails" candidate installed
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Offline Mode
|
||||
|
||||
Background:
|
||||
Given the internet is not reachable
|
||||
And an initialised environment
|
||||
|
||||
# list command
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Feature: Self Update
|
||||
|
||||
Background:
|
||||
Given an initialised system
|
||||
And an outdated system
|
||||
Given an outdated system
|
||||
And the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Upgrade an outdated installation
|
||||
When I enter "gvm selfupdate"
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Uninstall Candidate
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Uninstall an installed Candidate Version not in use
|
||||
Given the candidate "grails" version "2.1.0" is already installed but not default
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Use and Default Candidate
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Use without providing a Candidate
|
||||
When I enter "gvm use"
|
||||
|
||||
@@ -2,6 +2,7 @@ Feature: Version
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised environment
|
||||
|
||||
Scenario: Show the current version of gvm
|
||||
When I enter "gvm version"
|
||||
|
||||
@@ -3,7 +3,10 @@ package gvm
|
||||
import static cucumber.api.groovy.Hooks.*
|
||||
import static gvm.VertxUtils.*
|
||||
|
||||
serviceUrlEnv = "http://localhost:8080"
|
||||
SERVICE_DOWN_URL = "http://localhost:0"
|
||||
SERVICE_UP_URL = "http://localhost:8080"
|
||||
FAKE_JDK_PATH = "/path/to/my/openjdk"
|
||||
|
||||
forceOffline = false
|
||||
buildScriptDir = new File("build/testScripts")
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ import java.util.zip.ZipFile
|
||||
|
||||
import static cucumber.api.groovy.EN.*
|
||||
|
||||
final SERVICE_DOWN = "http://localhost:0"
|
||||
final FAKE_JDK_PATH = "/path/to/my/openjdk"
|
||||
|
||||
Then(~'^the gvm work folder is created$') { ->
|
||||
assert gvmDir.isDirectory(), "The gvm directory does not exist."
|
||||
}
|
||||
@@ -16,10 +13,6 @@ Then(~'^the "([^"]*)" folder exists in user home$') { String arg1 ->
|
||||
assert gvmDir.isDirectory(), "The gvm directory does not exist."
|
||||
}
|
||||
|
||||
Given(~'^an initialised system$') { ->
|
||||
gvmDir.mkdirs()
|
||||
}
|
||||
|
||||
When(~'^the archive for candidate "([^"]*)" version "([^"]*)" is corrupt$') { String candidate, String version ->
|
||||
try {
|
||||
new ZipFile(new File("src/test/resources/${candidate}-${version}.zip"))
|
||||
@@ -51,36 +44,41 @@ When(~'^I reinitialise the shell$') { ->
|
||||
}
|
||||
|
||||
Given(~'^the internet is reachable$') {->
|
||||
def forceOffline = "false"
|
||||
def online = "true"
|
||||
initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, serviceUrlEnv, FAKE_JDK_PATH)
|
||||
forceOffline = "false"
|
||||
online = "true"
|
||||
serviceUrlEnv = SERVICE_UP_URL
|
||||
javaHome = FAKE_JDK_PATH
|
||||
}
|
||||
|
||||
Given(~'^the internet is not reachable$') {->
|
||||
def forceOffline = "false"
|
||||
def online = "false"
|
||||
initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, SERVICE_DOWN, FAKE_JDK_PATH)
|
||||
forceOffline = "false"
|
||||
online = "false"
|
||||
serviceUrlEnv = SERVICE_DOWN_URL
|
||||
javaHome = FAKE_JDK_PATH
|
||||
}
|
||||
|
||||
And(~'^offline mode is disabled with reachable internet$') {->
|
||||
def forceOffline = "false"
|
||||
def online = "true"
|
||||
initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, serviceUrlEnv, FAKE_JDK_PATH)
|
||||
forceOffline = "false"
|
||||
online = "true"
|
||||
serviceUrlEnv = SERVICE_UP_URL
|
||||
javaHome = FAKE_JDK_PATH
|
||||
}
|
||||
|
||||
And(~'^offline mode is enabled with reachable internet$') {->
|
||||
def forceOffline = "true"
|
||||
def online = "true"
|
||||
initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, serviceUrlEnv, FAKE_JDK_PATH)
|
||||
forceOffline = "true"
|
||||
online = "true"
|
||||
serviceUrlEnv = SERVICE_UP_URL
|
||||
javaHome = FAKE_JDK_PATH
|
||||
}
|
||||
|
||||
And(~'^offline mode is enabled with unreachable internet$') {->
|
||||
def forceOffline = "true"
|
||||
def online = "false"
|
||||
initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, SERVICE_DOWN, FAKE_JDK_PATH)
|
||||
forceOffline = "true"
|
||||
online = "false"
|
||||
serviceUrlEnv = SERVICE_DOWN_URL
|
||||
javaHome = FAKE_JDK_PATH
|
||||
}
|
||||
|
||||
private initialiseEnvironment(gvmBaseEnv, gvmDirEnv, online, forceOffline, serviceUrlEnv, javaHome){
|
||||
And(~'^an initialised environment$') {->
|
||||
bash = new BashEnv(gvmBaseEnv, [GVM_DIR: gvmDirEnv, GVM_ONLINE:online, GVM_FORCE_OFFLINE: forceOffline, GVM_SERVICE: serviceUrlEnv, JAVA_HOME: javaHome])
|
||||
bash.start()
|
||||
bash.execute("source $gvmDirEnv/bin/gvm-init.sh")
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.nio.file.Path
|
||||
import static cucumber.api.groovy.EN.*
|
||||
|
||||
Given(~'^the default "([^"]*)" candidate is "([^"]*)"$') { String candidate, String version ->
|
||||
def candidateVersion = new URL("${serviceUrlEnv}/candidates/${candidate}/default").text
|
||||
def candidateVersion = new URL("${SERVICE_UP_URL}/candidates/${candidate}/default").text
|
||||
assert candidateVersion == version
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ Given(~'^I do not have a "([^"]*)" candidate installed$') { String candidate ->
|
||||
}
|
||||
|
||||
Given(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version ->
|
||||
def versions = new URL("${serviceUrlEnv}/candidates/${candidate}").text
|
||||
def versions = new URL("${SERVICE_UP_URL}/candidates/${candidate}").text
|
||||
assert ! versions.contains(version)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user