send-email: add tests for refactored prompting
Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6e1825186b
commit
c18f75a1e9
@ -421,8 +421,8 @@ test_confirm () {
|
|||||||
--from="Example <nobody@example.com>" \
|
--from="Example <nobody@example.com>" \
|
||||||
--to=nobody@example.com \
|
--to=nobody@example.com \
|
||||||
--smtp-server="$(pwd)/fake.sendmail" \
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
$@ \
|
$@ $patches > stdout &&
|
||||||
$patches | grep "Send this email"
|
grep "Send this email" stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success '--confirm=always' '
|
test_expect_success '--confirm=always' '
|
||||||
@ -444,8 +444,10 @@ test_expect_success '--confirm=compose' '
|
|||||||
test_expect_success 'confirm by default (due to cc)' '
|
test_expect_success 'confirm by default (due to cc)' '
|
||||||
CONFIRM=$(git config --get sendemail.confirm) &&
|
CONFIRM=$(git config --get sendemail.confirm) &&
|
||||||
git config --unset sendemail.confirm &&
|
git config --unset sendemail.confirm &&
|
||||||
test_confirm &&
|
test_confirm
|
||||||
git config sendemail.confirm $CONFIRM
|
ret="$?"
|
||||||
|
git config sendemail.confirm ${CONFIRM:-never}
|
||||||
|
test $ret = "0"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'confirm by default (due to --compose)' '
|
test_expect_success 'confirm by default (due to --compose)' '
|
||||||
@ -457,6 +459,48 @@ test_expect_success 'confirm by default (due to --compose)' '
|
|||||||
test $ret = "0"
|
test $ret = "0"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'confirm detects EOF (inform assumes y)' '
|
||||||
|
CONFIRM=$(git config --get sendemail.confirm) &&
|
||||||
|
git config --unset sendemail.confirm &&
|
||||||
|
GIT_SEND_EMAIL_NOTTY=1 \
|
||||||
|
git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
$patches < /dev/null
|
||||||
|
ret="$?"
|
||||||
|
git config sendemail.confirm ${CONFIRM:-never}
|
||||||
|
test $ret = "0"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'confirm detects EOF (auto causes failure)' '
|
||||||
|
CONFIRM=$(git config --get sendemail.confirm) &&
|
||||||
|
git config sendemail.confirm auto &&
|
||||||
|
GIT_SEND_EMAIL_NOTTY=1 \
|
||||||
|
test_must_fail git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
$patches < /dev/null
|
||||||
|
ret="$?"
|
||||||
|
git config sendemail.confirm ${CONFIRM:-never}
|
||||||
|
test $ret = "0"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'confirm doesnt loop forever' '
|
||||||
|
CONFIRM=$(git config --get sendemail.confirm) &&
|
||||||
|
git config sendemail.confirm auto &&
|
||||||
|
yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \
|
||||||
|
test_must_fail git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
$patches
|
||||||
|
ret="$?"
|
||||||
|
git config sendemail.confirm ${CONFIRM:-never}
|
||||||
|
test $ret = "0"
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success '--compose adds MIME for utf8 body' '
|
test_expect_success '--compose adds MIME for utf8 body' '
|
||||||
clean_fake_sendmail &&
|
clean_fake_sendmail &&
|
||||||
(echo "#!$SHELL_PATH" &&
|
(echo "#!$SHELL_PATH" &&
|
||||||
|
Reference in New Issue
Block a user