mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
fix change_url tests
This commit is contained in:
parent
e8d9b50e5d
commit
612d531e41
2 changed files with 43 additions and 11 deletions
18
lib/tests.sh
18
lib/tests.sh
|
@ -534,8 +534,11 @@ TEST_CHANGE_URL () {
|
||||||
at_least_one_install_succeeded || return 1
|
at_least_one_install_succeeded || return 1
|
||||||
this_is_a_web_app || return 0
|
this_is_a_web_app || return 0
|
||||||
|
|
||||||
|
local current_domain=$SUBDOMAIN
|
||||||
|
local current_path="$(default_install_path)"
|
||||||
|
|
||||||
log_small_title "Preliminary install..." \
|
log_small_title "Preliminary install..." \
|
||||||
&& _LOAD_SNAPSHOT_OR_INSTALL_APP "/"
|
&& _LOAD_SNAPSHOT_OR_INSTALL_APP "$current_path"
|
||||||
|
|
||||||
local ret=$?
|
local ret=$?
|
||||||
[ $ret -eq 0 ] || { return 1; }
|
[ $ret -eq 0 ] || { return 1; }
|
||||||
|
@ -577,13 +580,24 @@ TEST_CHANGE_URL () {
|
||||||
local new_domain=$DOMAIN
|
local new_domain=$DOMAIN
|
||||||
fi
|
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" \
|
&& _RUN_YUNOHOST_CMD "app change-url $app_id -d $new_domain -p $new_path" \
|
||||||
&& _VALIDATE_THAT_APP_CAN_BE_ACCESSED $new_domain $new_path
|
&& _VALIDATE_THAT_APP_CAN_BE_ACCESSED $new_domain $new_path
|
||||||
|
|
||||||
local ret=$?
|
local ret=$?
|
||||||
[ $ret -eq 0 ] || { return 1; }
|
[ $ret -eq 0 ] || { return 1; }
|
||||||
|
|
||||||
|
current_domain=$new_domain
|
||||||
|
current_path=$new_path
|
||||||
|
|
||||||
break_before_continue
|
break_before_continue
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -378,22 +378,40 @@ start_test () {
|
||||||
current_test_number=$((current_test_number+1))
|
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"
|
for TEST in $TEST_CONTEXT/tests/*.json
|
||||||
# installs should be a good indicator for the fact that it's not a webapp
|
|
||||||
for TEST in $(ls $TEST_CONTEXT/tests/*.json)
|
|
||||||
do
|
do
|
||||||
jq -e '. | select(.test_type == "TEST_INSTALL") | select(.test_arg == "nourl")' $TEST > /dev/null \
|
jq --arg install_type "$install_type" -e '. | select(.test_type == "TEST_INSTALL") | select(.test_arg == $install_type)' $TEST > /dev/null \
|
||||||
&& return 1
|
&& return 0
|
||||||
done
|
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() {
|
default_install_path() {
|
||||||
# All webapps should be installable at the root of a domain ?
|
# All webapps should be installable at the root or in a subpath of a domain
|
||||||
this_is_a_web_app && echo "/" || echo ""
|
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() {
|
path_to_install_type() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue