From: Oleg Broytman Date: Sat, 15 Mar 2014 20:23:58 +0000 (+0400) Subject: Add tests for --save-* X-Git-Tag: v2.5.0~7 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=006a9503ec8ea892ea9381de8d11865481b00096;p=mimedecode.git Add tests for --save-* --- diff --git a/TODO b/TODO index 70b4158..1970f5c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -Add tests for --save-*. - - Release 2.5.0. diff --git a/test/expected-save/msg_07-1.txt b/test/expected-save/msg_07-1.txt new file mode 100644 index 0000000..0ddf15f --- /dev/null +++ b/test/expected-save/msg_07-1.txt @@ -0,0 +1,5 @@ +Content-Type: image/gif; name="dingusfish.gif" +Content-Transfer-Encoding: 8bit +content-disposition: attachment; filename="dingusfish.gif" +X-MIME-Autoconverted: from base64 to 8bit by test id mimedecode.py + diff --git a/test/expected-save/msg_07-2.txt b/test/expected-save/msg_07-2.txt new file mode 100644 index 0000000..5587183 Binary files /dev/null and b/test/expected-save/msg_07-2.txt differ diff --git a/test/expected-save/msg_07-3.txt b/test/expected-save/msg_07-3.txt new file mode 100644 index 0000000..cc8962b Binary files /dev/null and b/test/expected-save/msg_07-3.txt differ diff --git a/test/test_all b/test/test_all index c7bdb28..5009f70 100755 --- a/test/test_all +++ b/test/test_all @@ -4,7 +4,7 @@ cd "`dirname \"$0\"`" && MAILCAPS="`pwd`"/.mailcap && export MAILCAPS && -rm -rf tmp && +rm -rf save tmp && mkdir tmp || exit 1 RC=0 @@ -61,9 +61,42 @@ test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test:set test_file msg_13.txt msg_13-1.txt -B '*/*' test_file msg_13.txt msg_13.txt -t 'text/*' -b 'image/*' -B '*/*' +# Test --save-* +test2() { + infile="$1" + shift + expfile="$1" + shift + savefile="$1" + shift + expsavefile="$1" + shift + + test_file "$infile" "$expfile" -O save "$@" + + if cmp -s expected-save/"$expsavefile" save/"$savefile"; then + rm save/"$savefile" && return 0 || return 1 + else + return 1 + fi +} + +test_save() { + if test2 "$@"; then + echo " save: ok" + else + echo " save: fail" + RC=1 + fi +} + +test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-1.txt --save-headers image/gif +test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-2.txt --save-body image/gif +test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-3.txt --save-message image/gif + if [ "$RC" -eq 0 ]; then echo "All tests passed!" - rmdir tmp + rmdir save tmp fi exit $RC