mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-08-02 18:46:29 -04:00
Do not go offline when curl times out on initialisation.
This commit is contained in:
@@ -51,17 +51,17 @@ function gvm_set_candidates {
|
||||
}
|
||||
|
||||
function gvm_check_offline {
|
||||
RESPONSE="$1"
|
||||
DETECT_HTML="$(echo "$RESPONSE" | tr '[:upper:]' '[:lower:]' | grep 'html')"
|
||||
if [[ -z "$RESPONSE" || -n "$DETECT_HTML" ]]; then
|
||||
GVM_RESPONSE="$1"
|
||||
GVM_DETECT_HTML="$(echo "$GVM_RESPONSE" | tr '[:upper:]' '[:lower:]' | grep 'html')"
|
||||
if [[ -n "$GVM_DETECT_HTML" ]]; then
|
||||
echo "GVM can't reach the internet so going offline. Re-enable online with:"
|
||||
echo ""
|
||||
echo " $ gvm offline disable"
|
||||
echo ""
|
||||
GVM_FORCE_OFFLINE="true"
|
||||
fi
|
||||
unset RESPONSE
|
||||
unset DETECT_HTML
|
||||
unset GVM_RESPONSE
|
||||
unset GVM_DETECT_HTML
|
||||
}
|
||||
|
||||
# force zsh to behave well
|
||||
|
||||
@@ -140,7 +140,7 @@ class BootstrapSpec extends Specification {
|
||||
bash = GvmBashEnvBuilder
|
||||
.create(gvmBaseDir)
|
||||
.withCurlStub(curlStub)
|
||||
.withVersionToken("x.y.z")
|
||||
.withVersionToken(gvmVersion)
|
||||
.withConfiguration("gvm_auto_selfupdate", "true")
|
||||
.build()
|
||||
bash.start()
|
||||
@@ -151,7 +151,25 @@ class BootstrapSpec extends Specification {
|
||||
then:
|
||||
! bash.output.contains("A new version of GVM is available...")
|
||||
versionFile.text.contains(gvmVersion)
|
||||
}
|
||||
|
||||
void "should not go offline if curl times out"(){
|
||||
given: 'a working gvm installation with api down'
|
||||
def gvmVersion = "x.y.z"
|
||||
def versionFile = new File(versionToken)
|
||||
curlStub.primeWith("http://localhost:8080/app/version", "echo ''").build()
|
||||
bash = GvmBashEnvBuilder
|
||||
.create(gvmBaseDir)
|
||||
.withCurlStub(curlStub)
|
||||
.withConfiguration("gvm_auto_selfupdate", "true")
|
||||
.build()
|
||||
bash.start()
|
||||
|
||||
when: 'bootstrap the system'
|
||||
bash.execute("source $bootstrap")
|
||||
|
||||
then:
|
||||
! bash.output.contains("GVM can't reach the internet so going offline.")
|
||||
}
|
||||
|
||||
void "should ignore version if api returns garbage"(){
|
||||
|
||||
Reference in New Issue
Block a user