diff --git a/test/mock/icfs_dialogue b/test/mock/icfs_dialogue index 92f8aff..99ef036 100755 --- a/test/mock/icfs_dialogue +++ b/test/mock/icfs_dialogue @@ -1,29 +1,41 @@ #!/bin/bash -# fake-zenity: script that mocks the behavior of zenity based on the ./.fake-zenity-response file +# fake-icfs_dialogue: script that mocks the behavior of icfs_dialogue based on the ./.fake-icfs_dialogue-response file -ZENITY_YES=0 -ZENITY_NO=1 -ZENITY_PERM=2 +ICFS_DIALOGUE_YES=0 +ICFS_DIALOGUE_NO=1 +ICFS_DIALOGUE_PERM=2 if [[ $1 == "--set-fake-response" ]]; then #someone knows we are fake :) - echo "$2" >~/.fake_zenity_response + echo "$2" >~/.fake_icfs_dialogue_response +elif [[ $1 == "--set-fake-response-filename" ]]; then + echo "$2" >~/.fake_icfs_dialogue_response_filename +elif [[ $1 == "--reset-fake-response" ]]; then + rm ~/.fake_icfs_dialogue_response ~/.fake_icfs_dialogue_response_filename else - if [ -f ~/.fake_zenity_response ]; then - FAKE_ZENITY_RESPONSE=$(cat ~/.fake_zenity_response) + if [ -f ~/.fake_icfs_dialogue_response ]; then + FAKE_ICFS_DIALOGUE_RESPONSE=$(cat ~/.fake_icfs_dialogue_response) - printf "%s" "$4" - if [[ $FAKE_ZENITY_RESPONSE == "yes" ]]; then - exit "$ZENITY_YES" - elif [[ $FAKE_ZENITY_RESPONSE == "no" ]]; then - exit "$ZENITY_NO" - elif [[ $FAKE_ZENITY_RESPONSE == "yes_perm" ]]; then - exit "$((ZENITY_YES | ZENITY_PERM))" - elif [[ $FAKE_ZENITY_RESPONSE == "no_perm" ]]; then - exit "$((ZENITY_NO | ZENITY_PERM))" + if [[ -f ~/.fake_icfs_dialogue_response_filename ]]; then + FAKE_ICFS_DIALOGUE_RESPONSE_FILENAME=$(cat ~/.fake_icfs_dialogue_response_filename) + if [[ $FAKE_ICFS_DIALOGUE_RESPONSE_FILENAME == "" ]]; then + printf "%s" "$4" + else + printf "%s" "$(cat ~/.fake_icfs_dialogue_response_filename)" + fi + fi + + if [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "yes" ]]; then + exit "$ICFS_DIALOGUE_YES" + elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "no" ]]; then + exit "$ICFS_DIALOGUE_NO" + elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "yes_perm" ]]; then + exit "$((ICFS_DIALOGUE_YES | ICFS_DIALOGUE_PERM))" + elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "no_perm" ]]; then + exit "$((ICFS_DIALOGUE_NO | ICFS_DIALOGUE_PERM))" fi fi fi -exit 255 # TODO: call actual zenity here +exit 255 # TODO: call actual icfs_dialogue here