test/send-email: --[no-]xmailer tests

Add tests for the --[no-]xmailer option. Signed-off-by: Luis Henriques <henrix@camandro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Luis Henriques committed Dec 4, 2014 at 19:11 UTC 2cf770f50185fc7a1e3aaa0463eb452d32517f83
1 file changed +33
t/t9001-send-email.sh
+33
@@ -1407,4 +1407,37 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1407 grep "^!someone@example\.org!$" commandline1
1408 '
1409
1410 +do_xmailer_test () {
1411 + expected=$1 params=$2 &&
1412 + git format-patch -1 &&
1413 + git send-email \
1414 + --from="Example <nobody@example.com>" \
1415 + --to=someone@example.com \
1416 + --smtp-server="$(pwd)/fake.sendmail" \
1417 + $params \
1418 + 0001-*.patch \
1419 + 2>errors >out &&
1420 + { grep '^X-Mailer:' out || :; } >mailer &&
1421 + test_line_count = $expected mailer
1422 +}
1423 +
1424 +test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
1425 + do_xmailer_test 1 "--xmailer" &&
1426 + do_xmailer_test 0 "--no-xmailer"
1427 +'
1428 +
1429 +test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
1430 + test_config sendemail.xmailer true &&
1431 + do_xmailer_test 1 "" &&
1432 + do_xmailer_test 0 "--no-xmailer" &&
1433 + do_xmailer_test 1 "--xmailer"
1434 +'
1435 +
1436 +test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
1437 + test_config sendemail.xmailer false &&
1438 + do_xmailer_test 0 "" &&
1439 + do_xmailer_test 0 "--no-xmailer" &&
1440 + do_xmailer_test 1 "--xmailer"
1441 +'
1442 +
1443 test_done