diff options
Diffstat (limited to 't/t9001-send-email.sh')
-rwxr-xr-x | t/t9001-send-email.sh | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 1a1caf8f2e..3b7540050c 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -415,15 +415,23 @@ test_expect_success $PREREQ 'reject long lines' ' z512=$z64$z64$z64$z64$z64$z64$z64$z64 && clean_fake_sendmail && cp $patches longline.patch && - echo $z512$z512 >>longline.patch && + cat >>longline.patch <<-EOF && + $z512$z512 + not a long line + $z512$z512 + EOF test_must_fail git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ --transfer-encoding=8bit \ $patches longline.patch \ - 2>errors && - grep longline.patch errors + 2>actual && + cat >expect <<-\EOF && + fatal: longline.patch:35 is longer than 998 characters + warning: no patches were sent + EOF + test_cmp expect actual ' test_expect_success $PREREQ 'no patch was sent' ' @@ -527,22 +535,33 @@ test_expect_success $PREREQ "--validate respects relative core.hooksPath path" ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ --validate \ - longline.patch 2>err && + longline.patch 2>actual && test_path_is_file my-hooks.ran && - grep "rejected by sendemail-validate" err + cat >expect <<-EOF && + fatal: longline.patch: rejected by sendemail-validate hook + fatal: command '"'"'my-hooks/sendemail-validate'"'"' died with exit code 1 + warning: no patches were sent + EOF + test_cmp expect actual ' test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" ' - test_config core.hooksPath "$(pwd)/my-hooks" && + hooks_path="$(pwd)/my-hooks" && + test_config core.hooksPath "$hooks_path" && test_when_finished "rm my-hooks.ran" && test_must_fail git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ --validate \ - longline.patch 2>err && + longline.patch 2>actual && test_path_is_file my-hooks.ran && - grep "rejected by sendemail-validate" err + cat >expect <<-EOF && + fatal: longline.patch: rejected by sendemail-validate hook + fatal: command '"'"'$hooks_path/sendemail-validate'"'"' died with exit code 1 + warning: no patches were sent + EOF + test_cmp expect actual ' for enc in 7bit 8bit quoted-printable base64 @@ -625,14 +644,33 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' test_cmp expect actual ' +test_set_editor "$(pwd)/fake-editor" + +test_expect_success $PREREQ 'setup erroring fake editor' ' + write_script fake-editor <<-\EOF + echo >&2 "I am about to error" + exit 1 + EOF +' + +test_expect_success $PREREQ 'fake editor dies with error' ' + clean_fake_sendmail && + test_must_fail git send-email \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches 2>err && + grep "I am about to error" err && + grep "the editor exited uncleanly, aborting everything" err +' + test_expect_success $PREREQ 'setup fake editor' ' write_script fake-editor <<-\EOF echo fake edit >>"$1" EOF ' -test_set_editor "$(pwd)/fake-editor" - test_expect_success $PREREQ '--compose works' ' clean_fake_sendmail && git send-email \ |