diff --git a/lib/tests.sh b/lib/tests.sh index cb0b038..d9c8583 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -534,8 +534,11 @@ TEST_CHANGE_URL () { at_least_one_install_succeeded || return 1 this_is_a_web_app || return 0 + local current_domain=$SUBDOMAIN + local current_path="$(default_install_path)" + log_small_title "Preliminary install..." \ - && _LOAD_SNAPSHOT_OR_INSTALL_APP "/" + && _LOAD_SNAPSHOT_OR_INSTALL_APP "$current_path" local ret=$? [ $ret -eq 0 ] || { return 1; } @@ -577,13 +580,24 @@ TEST_CHANGE_URL () { local new_domain=$DOMAIN fi - log_small_title "Changing the url to $new_domain$new_path..." \ + if [ "$new_path" == "$current_path" ] && [ "$new_domain" == "$current_domain" ]; then + continue + elif ! there_is_a_root_install_test && [ "$new_path" == "/" ]; then + continue + elif ! there_is_a_subdir_install_test && [ "$new_path" != "/" ]; then + continue + fi + + log_small_title "Changing the url from $current_domain$current_path to $new_domain$new_path..." \ && _RUN_YUNOHOST_CMD "app change-url $app_id -d $new_domain -p $new_path" \ && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $new_domain $new_path local ret=$? [ $ret -eq 0 ] || { return 1; } + current_domain=$new_domain + current_path=$new_path + break_before_continue done diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 76c702d..8e330b0 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -378,22 +378,40 @@ start_test () { current_test_number=$((current_test_number+1)) } -this_is_a_web_app () { +there_is_an_install_type() { + local install_type=$1 - # Usually the fact that we test "nourl" - # installs should be a good indicator for the fact that it's not a webapp - for TEST in $(ls $TEST_CONTEXT/tests/*.json) + for TEST in $TEST_CONTEXT/tests/*.json do - jq -e '. | select(.test_type == "TEST_INSTALL") | select(.test_arg == "nourl")' $TEST > /dev/null \ - && return 1 + jq --arg install_type "$install_type" -e '. | select(.test_type == "TEST_INSTALL") | select(.test_arg == $install_type)' $TEST > /dev/null \ + && return 0 done - return 0 + return 1 +} + +there_is_a_root_install_test() { + return $(there_is_an_install_type "root") +} + +there_is_a_subdir_install_test() { + return $(there_is_an_install_type "subdir") +} + +this_is_a_web_app () { + # An app is considered to be a webapp if there is a root or a subdir test + return $(there_is_a_root_install_test) || $(there_is_a_subdir_install_test) } default_install_path() { - # All webapps should be installable at the root of a domain ? - this_is_a_web_app && echo "/" || echo "" + # All webapps should be installable at the root or in a subpath of a domain + if there_is_a_root_install_test; then + echo "/" + elif there_is_a_subdir_install_test; then + echo "/path" + else + echo "" + fi } path_to_install_type() {