Issue #4 and #12: Check for presence of candidate and version. Also bolstered list and use commands.

This commit is contained in:
Marco Vermeulen
2012-10-09 13:18:24 +01:00
parent eeb59c4d7b
commit d294c9cdf0
4 changed files with 28 additions and 10 deletions

View File

@@ -18,9 +18,8 @@ Feature: Command Line Interop
Scenario: Enter an invalid Candidate
When I enter "gvm install groffle"
Then I see "Invalid candidate: groffle"
And I see "Usage: gvm <command> <candidate> [version]"
Then I see "Stop! groffle is not a valid candidate."
Scenario: Use without providing a Candidate
When I enter "gvm use"
Then I see "Usage: gvm <command> <candidate> [version]"
Then I see "Usage: gvm <command> <candidate> [version]"

View File

@@ -19,4 +19,16 @@ Feature: Uninstall Candidate
When I enter "gvm uninstall grails 1.3.9"
Then I see "grails 1.3.9 is not installed."
And the candidate "grails" version "1.3.9" is not installed
Scenario: Attempt uninstalling with no Candidate specified
When I enter "gvm uninstall"
Then I see "No candidate provided."
Scenario: Attempt uninstalling with an invalid Candidate specified
When I enter "gvm uninstall groffle"
Then I see "Stop! groffle is not a valid candidate."
Scenario: Attempt uninstalling without a version provided
When I enter "gvm uninstall grails"
Then I see "No candidate version provided."

View File

@@ -10,7 +10,7 @@ class VertxUtils {
final static candidates = [grails:grails]
final static defaults = [grails:'2.1.0']
static final gvmVersion = '0.1'
static final gvmVersion = '0.3'
static final serverVersion = '0.1'
static final vertxVersion = '1.2.3.final'
@@ -93,7 +93,7 @@ class VertxUtils {
binding = [server:serverVersion, vertx:vertxVersion]
} else {
gtplFile = new File('srv/templates/upgrade.gtpl')
binding = [version:gvmVersion]
binding = [version:version, gvmVersion:gvmVersion]
}
def template = templateEngine.createTemplate(gtplFile).make(binding)
req.response.end template.toString()

View File

@@ -26,6 +26,14 @@ function check_candidate_present {
fi
}
function check_version_present {
if [ -z "$1" ]; then
echo -e "\nNo candidate version provided."
help
exit 0
fi
}
function determine_candidate_version {
if [ -z "$1" ]; then
VERSION=$(curl -s "$GVM_SERVICE/candidates/$CANDIDATE/default")
@@ -168,11 +176,7 @@ function gvm-install {
function gvm-use {
CANDIDATE="$1"
if [ -z "$2" ]; then
help
exit 0
fi
check_candidate_present "$CANDIDATE"
determine_candidate_version "$2"
check_not_installed
@@ -187,6 +191,7 @@ function gvm-use {
function gvm-list {
CANDIDATE="$1"
check_candidate_present "$CANDIDATE"
build_version_csv "$CANDIDATE"
determine_current_version "$CANDIDATE"
FRAGMENT=$(curl -s "$GVM_SERVICE/candidates/$CANDIDATE/list?current=$CURRENT&installed=$CSV")
@@ -196,6 +201,8 @@ function gvm-list {
function gvm-uninstall {
CANDIDATE="$1"
VERSION="$2"
check_candidate_present "$CANDIDATE"
check_version_present "$VERSION"
CURRENT=$(readlink "$GVM_DIR/$CANDIDATE/current" | sed -e "s_$GVM_DIR/$CANDIDATE/__g")
if [ -h "$GVM_DIR/$CANDIDATE/current" -a "$VERSION" == "$CURRENT" ]; then
echo ""