From d80bbff2b970ccbc0c7bc98dc5e325eea9b0586d Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Fri, 24 Mar 2017 17:22:52 -0500 Subject: [PATCH] Acceptance tests for encrypt globs and paths with space (#53, #54) --- test/108_accept_alt.bats | 5 +++- test/109_accept_encryption.bats | 51 +++++++++++++++++++++++++++++---- test/common.bash | 2 ++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/test/108_accept_alt.bats b/test/108_accept_alt.bats index b904ac7..72d1cdb 100644 --- a/test/108_accept_alt.bats +++ b/test/108_accept_alt.bats @@ -10,7 +10,7 @@ function create_encrypt() { echo "$efile" >> "$T_YADM_ENCRYPT" echo "$efile" >> "$T_DIR_WORK/$efile" mkdir -p "$T_DIR_WORK/dir one/$efile" - echo "dir one/$efile/file1" >> "$T_YADM_ENCRYPT" + echo "'dir one'/$efile/file1" >> "$T_YADM_ENCRYPT" echo "dir one/$efile/file1" >> "$T_DIR_WORK/dir one/$efile/file1" done } @@ -97,8 +97,11 @@ function test_alt() { if [ -z "$auto_alt" ]; then run "${T_YADM_Y[@]}" alt #; validate status and output + echo "TEST:Link Name:$link_name" + echo "TEST:DIR Link Name:$dir_link_name" if [ "$status" != 0 ] || [[ ! "$output" =~ Linking.+$link_name ]] || [[ ! "$output" =~ Linking.+$dir_link_name ]]; then echo "OUTPUT:$output" + echo "STATUS:$status" echo "ERROR: Could not confirm status and output of alt command" return 1; fi diff --git a/test/109_accept_encryption.bats b/test/109_accept_encryption.bats index 0412e68..33280e1 100644 --- a/test/109_accept_encryption.bats +++ b/test/109_accept_encryption.bats @@ -93,9 +93,14 @@ EOF if cd "$T_DIR_WORK"; then # shellcheck disable=2013 # (globbing is desired) - for f in $(cat "$T_YADM_ENCRYPT"); do - echo "$f" - done | sort > "$T_TMP/expected_list" + while IFS='' read -r glob || [ -n "$glob" ]; do + if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then + local IFS=$'\n' + for matching_file in $(eval ls "$glob" 2>/dev/null); do + echo "$matching_file" + done + fi + done < "$T_YADM_ENCRYPT" | sort > "$T_TMP/expected_list" fi ) @@ -104,6 +109,8 @@ EOF echo "ERROR: Archive does not contain the correct files" echo "Contains:" cat "$T_TMP/archive_list" + echo "Expected:" + cat "$T_TMP/expected_list" return 1 fi return 0 @@ -196,7 +203,7 @@ EOF validate_archive symmetric } -@test "Command 'encrypt' (comments in YADM_ARCHIVE)" { +@test "Command 'encrypt' (comments in YADM_ENCRYPT)" { echo " When 'encrypt' command is provided, and YADM_ENCRYPT is present @@ -233,7 +240,7 @@ EOF validate_archive symmetric } -@test "Command 'encrypt' (empty lines and space lines in YADM_ARCHIVE)" { +@test "Command 'encrypt' (empty lines and space lines in YADM_ENCRYPT)" { echo " When 'encrypt' command is provided, and YADM_ENCRYPT is present @@ -270,6 +277,40 @@ EOF validate_archive symmetric } +@test "Command 'encrypt' (paths with spaces/globs in YADM_ENCRYPT)" { + echo " + When 'encrypt' command is provided, + and YADM_ENCRYPT is present + Create YADM_ARCHIVE + Report the archive created + Archive should be valid + Exit with 0 + " + + #; add paths with spaces to YADM_ARCHIVE + local original_encrypt + original_encrypt=$(cat "$T_YADM_ENCRYPT") + echo -e "'space test'/file*" >> "$T_YADM_ENCRYPT" + + #; run encrypt + run expect <