From 2d5a8813ab920293a48823d44cb13fb66fbe9dd5 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 6 Dec 2017 08:56:40 +0000 Subject: [PATCH] Make tweaks to presentation of update command. --- src/main/bash/sdkman-update.sh | 10 ++++++++-- src/test/cucumber/update.feature | 16 +++++++--------- .../specs/CandidatesCacheUpdateSpec.groovy | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/bash/sdkman-update.sh b/src/main/bash/sdkman-update.sh index c6d3327b..ebf4bbdf 100644 --- a/src/main/bash/sdkman-update.sh +++ b/src/main/bash/sdkman-update.sh @@ -47,13 +47,19 @@ function __sdk_update { local diff=$(echo ${fresh_candidates[@]} ${cached_candidates[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ',') if (( fresh_candidates_length > cached_candidates_length )); then - __sdkman_echo_yellow "New candidates(s) found: ${diff:0:-1}" + echo "" + __sdkman_echo_green "Adding new candidates(s): ${diff:0:-1}" echo "$fresh_candidates_csv" > "$SDKMAN_CANDIDATES_CACHE" + echo "" + __sdkman_echo_yellow "Please open a new terminal now..." elif (( fresh_candidates_length < cached_candidates_length )); then local candidates_diff="${diff:0:-1}" - __sdkman_echo_yellow "Retired candidates(s) removed: ${diff:0:-1}" + echo "" + __sdkman_echo_green "Removing obsolete candidates(s): ${diff:0:-1}" echo "$fresh_candidates_csv" > "$SDKMAN_CANDIDATES_CACHE" + echo "" + __sdkman_echo_yellow "Please open a new terminal now..." else __sdkman_echo_green "No new candidates found at this time." diff --git a/src/test/cucumber/update.feature b/src/test/cucumber/update.feature index 27524afa..6541be5b 100644 --- a/src/test/cucumber/update.feature +++ b/src/test/cucumber/update.feature @@ -4,7 +4,7 @@ Feature: Update Given the internet is reachable And the following candidates are available for installation in local cache: | candidate | - | ceylon | + | activator | | groovy | | scala | And an initialised environment @@ -13,13 +13,13 @@ Feature: Update Scenario: A new candidate is available And the following candidates are currently available from remote API: | candidate | - | ceylon | + | activator | | groovy | | kotlin | | scala | When I enter "sdk update" - Then I see "New candidates(s) found: kotlin" - And the Candidates cache should contain "ceylon,groovy,kotlin,scala" + Then I see "Adding new candidates(s): kotlin" + And the Candidates cache should contain "activator,groovy,kotlin,scala" Scenario: A candidate has been removed And the following candidates are currently available from remote API: @@ -27,17 +27,15 @@ Feature: Update | groovy | | scala | When I enter "sdk update" - Then I see "Retired candidates(s) removed: ceylon" + Then I see "Removing obsolete candidates(s): activator" And the Candidates cache should contain "groovy,scala" Scenario: No new candidate is available And the following candidates are currently available from remote API: | candidate | - | ceylon | + | activator | | groovy | | scala | When I enter "sdk update" Then I see "No new candidates found at this time." - And the Candidates cache should contain "ceylon,groovy,scala" - - Scenario: + And the Candidates cache should contain "activator,groovy,scala" \ No newline at end of file diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index a0e5bb25..3e9124a9 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -23,7 +23,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { sdkmanBashEnvBuilder.withConfiguration("sdkman_debug_mode", "true") } - void "should issue a warning if cache is empty"() { + void "should issue a warning and escape if cache is empty"() { given: bash = sdkmanBashEnvBuilder .withCandidates([]) @@ -106,7 +106,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { bash.execute("sdk update") then: - bash.output.contains('New candidates(s) found: groovy,scala') + bash.output.contains('Adding new candidates(s): groovy,scala') and: candidatesCache.text.trim() == "groovy,scala"