send-email: fix broken transferEncoding tests

I fixed a bug that had broken the reading of sendmail.transferEncoding in 3494dfd3ee ("send-email: do defaults -> config -> getopt in that order", 2019-05-09), but the test I added in that commit did nothing to assert the bug had been fixed. That issue originates in 8d81408435 ("git-send-email: add --transfer-encoding option", 2014-11-25) which first added the "sendemail.transferencoding=8bit". That test has never done anything meaningful. It tested that the "--transfer-encoding=8bit" option would turn on the 8bit Transfer-Encoding, but that was the default at the time (and now). As checking out 8d81408435 and editing the test to remove that option will reveal, supplying it never did anything. So when I copied it thinking it would work in 3494dfd3ee I copied a previously broken test, although I was making sure it did the right thing via da-hoc debugger inspection, so the bug was fixed. So fix the test I added in 3494dfd3ee, as well as the long-standing test added in 8d81408435. To test if we're actually setting the Transfer-Encoding let's set it to 7bit, not 8bit, as 7bit will error out on "email-using-8bit". This means that we can remove the "sendemail.transferencoding=7bit fails on 8bit data" test, since it was redundant, we now have other tests that assert that that'll fail. While I'm at it convert "git config <key> <value>" in the test setup to just "-c <key>=<value>" on the command-line. Then we don't need to cleanup after these tests, and there's no sense in asserting where config values come from in these tests, we can take that as a given. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 17, 2019 at 21:55 UTC a8aea5db7a174c29a34b2e1fad85aa2fcf33a687
1 file changed +11 -24
t/t9001-send-email.sh
+11 -24
@@ -1409,10 +1409,10 @@ test_expect_success $PREREQ 'setup expect' '
1409 EOF
1410 '
1411
1412 -test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1412 +test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1413 clean_fake_sendmail &&
1414 - git config sendemail.transferEncoding 7bit &&
1415 - test_must_fail git send-email \
1414 + test_must_fail git -c sendemail.transferEncoding=8bit \
1415 + send-email \
1416 --transfer-encoding=7bit \
1417 --smtp-server="$(pwd)/fake.sendmail" \
1418 email-using-8bit \
@@ -1421,11 +1421,10 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data'
1421 test -z "$(ls msgtxt*)"
1422 '
1423
1424 -test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1424 +test_expect_success $PREREQ 'sendemail.transferEncoding via config' '
1425 clean_fake_sendmail &&
1426 - git config sendemail.transferEncoding 8bit &&
1427 - test_must_fail git send-email \
1428 - --transfer-encoding=7bit \
1426 + test_must_fail git -c sendemail.transferEncoding=7bit \
1427 + send-email \
1428 --smtp-server="$(pwd)/fake.sendmail" \
1429 email-using-8bit \
1430 2>errors >out &&
@@ -1433,27 +1432,15 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc
1432 test -z "$(ls msgtxt*)"
1433 '
1434
1436 -test_expect_success $PREREQ 'sendemail.transferencoding=8bit via config' '
1435 +test_expect_success $PREREQ 'sendemail.transferEncoding via cli' '
1436 clean_fake_sendmail &&
1438 - git -c sendemail.transferencoding=8bit send-email \
1439 - --smtp-server="$(pwd)/fake.sendmail" \
1440 - email-using-8bit \
1441 - 2>errors >out &&
1442 - sed '1,/^$/d' msgtxt1 >actual &&
1443 - sed '1,/^$/d' email-using-8bit >expected &&
1444 - test_cmp expected actual
1445 -'
1446 -
1447 -test_expect_success $PREREQ 'sendemail.transferencoding=8bit via cli' '
1448 - clean_fake_sendmail &&
1449 - git send-email \
1450 - --transfer-encoding=8bit \
1437 + test_must_fail git send-email \
1438 + --transfer-encoding=7bit \
1439 --smtp-server="$(pwd)/fake.sendmail" \
1440 email-using-8bit \
1441 2>errors >out &&
1454 - sed '1,/^$/d' msgtxt1 >actual &&
1455 - sed '1,/^$/d' email-using-8bit >expected &&
1456 - test_cmp expected actual
1442 + grep "cannot send message as 7bit" errors &&
1443 + test -z "$(ls msgtxt*)"
1444 '
1445
1446 test_expect_success $PREREQ 'setup expect' '