send-email: add tests for refactored prompting
Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jay Soffian committed
Mar 28, 2009 at 21:39 UTC
c18f75a1e96ff0f028edf94effd10cf56d892f22
1 file changed
+48
-4
t/t9001-send-email.sh
+48
-4
@@ -421,8 +421,8 @@ test_confirm () {
421
--from="Example <nobody@example.com>" \
422
--to=nobody@example.com \
423
--smtp-server="$(pwd)/fake.sendmail" \
424
- $@ \
425
- $patches | grep "Send this email"
424
+ $@ $patches > stdout &&
425
+ grep "Send this email" stdout
426
}
427
428
test_expect_success '--confirm=always' '
@@ -444,8 +444,10 @@ test_expect_success '--confirm=compose' '
444
test_expect_success 'confirm by default (due to cc)' '
445
CONFIRM=$(git config --get sendemail.confirm) &&
446
git config --unset sendemail.confirm &&
447
- test_confirm &&
448
- git config sendemail.confirm $CONFIRM
447
+ test_confirm
448
+ ret="$?"
449
+ git config sendemail.confirm ${CONFIRM:-never}
450
+ test $ret = "0"
451
'
452
453
test_expect_success 'confirm by default (due to --compose)' '
@@ -457,6 +459,48 @@ test_expect_success 'confirm by default (due to --compose)' '
459
test $ret = "0"
460
'
461
462
+test_expect_success 'confirm detects EOF (inform assumes y)' '
463
+ CONFIRM=$(git config --get sendemail.confirm) &&
464
+ git config --unset sendemail.confirm &&
465
+ GIT_SEND_EMAIL_NOTTY=1 \
466
+ git send-email \
467
+ --from="Example <nobody@example.com>" \
468
+ --to=nobody@example.com \
469
+ --smtp-server="$(pwd)/fake.sendmail" \
470
+ $patches < /dev/null
471
+ ret="$?"
472
+ git config sendemail.confirm ${CONFIRM:-never}
473
+ test $ret = "0"
474
+'
475
+
476
+test_expect_success 'confirm detects EOF (auto causes failure)' '
477
+ CONFIRM=$(git config --get sendemail.confirm) &&
478
+ git config sendemail.confirm auto &&
479
+ GIT_SEND_EMAIL_NOTTY=1 \
480
+ test_must_fail git send-email \
481
+ --from="Example <nobody@example.com>" \
482
+ --to=nobody@example.com \
483
+ --smtp-server="$(pwd)/fake.sendmail" \
484
+ $patches < /dev/null
485
+ ret="$?"
486
+ git config sendemail.confirm ${CONFIRM:-never}
487
+ test $ret = "0"
488
+'
489
+
490
+test_expect_success 'confirm doesnt loop forever' '
491
+ CONFIRM=$(git config --get sendemail.confirm) &&
492
+ git config sendemail.confirm auto &&
493
+ yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \
494
+ test_must_fail git send-email \
495
+ --from="Example <nobody@example.com>" \
496
+ --to=nobody@example.com \
497
+ --smtp-server="$(pwd)/fake.sendmail" \
498
+ $patches
499
+ ret="$?"
500
+ git config sendemail.confirm ${CONFIRM:-never}
501
+ test $ret = "0"
502
+'
503
+
504
test_expect_success '--compose adds MIME for utf8 body' '
505
clean_fake_sendmail &&
506
(echo "#!$SHELL_PATH" &&