Add test case for supporting directories in .yadm/encrypt (#81)

This commit is contained in:
Tim Byrne 2017-09-04 12:59:13 -05:00
parent e09b5a551e
commit df952094a1
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
1 changed files with 43 additions and 2 deletions

View File

@ -96,8 +96,15 @@ EOF
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"
for matching_file in $(eval ls -d "$glob" 2>/dev/null); do
if [ -d "$matching_file" ]; then
echo "$matching_file/"
for subfile in "$matching_file"/*; do
echo "$subfile"
done
else
echo "$matching_file"
fi
done
fi
done < "$T_YADM_ENCRYPT" | sort > "$T_TMP/expected_list"
@ -311,6 +318,40 @@ EOF
validate_archive symmetric
}
@test "Command 'encrypt' (directories 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 directory paths to YADM_ARCHIVE
local original_encrypt
original_encrypt=$(cat "$T_YADM_ENCRYPT")
echo -e "'space test'" >> "$T_YADM_ENCRYPT"
#; run encrypt
run expect <<EOF
set timeout 2;
spawn ${T_YADM_Y[*]} encrypt;
expect "passphrase:" {send "$T_PASSWD\n"}
expect "passphrase:" {send "$T_PASSWD\n"}
expect "$"
foreach {pid spawnid os_error_flag value} [wait] break
exit \$value
EOF
#; validate status and output
[ "$status" -eq 0 ]
[[ "$output" =~ Wrote\ new\ file:.+$T_YADM_ARCHIVE ]]
#; validate the archive
validate_archive symmetric
}
@test "Command 'encrypt' (overwrite)" {
echo "
When 'encrypt' command is provided,