test/send-email: to-cover, cc-cover tests

Add tests for the new feature. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael S. Tsirkin committed Apr 29, 2014 at 08:41 UTC 8ccc4e42604636a38114fafa976ea9e25a578094
1 file changed +45
t/t9001-send-email.sh
+45
@@ -1334,6 +1334,51 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' '
1334 test -n "$(ls msgtxt*)"
1335 '
1336
1337 +test_cover_addresses () {
1338 + header="$1"
1339 + shift
1340 + clean_fake_sendmail &&
1341 + rm -fr outdir &&
1342 + git format-patch --cover-letter -2 -o outdir &&
1343 + cover=`echo outdir/0000-*.patch` &&
1344 + mv $cover cover-to-edit.patch &&
1345 + sed "s/^From:/$header: extra@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
1346 + git send-email \
1347 + --force \
1348 + --from="Example <nobody@example.com>" \
1349 + --no-to --no-cc \
1350 + "$@" \
1351 + --smtp-server="$(pwd)/fake.sendmail" \
1352 + outdir/0000-*.patch \
1353 + outdir/0001-*.patch \
1354 + outdir/0002-*.patch \
1355 + 2>errors >out &&
1356 + grep "^$header: extra@address.com" msgtxt1 >to1 &&
1357 + grep "^$header: extra@address.com" msgtxt2 >to2 &&
1358 + grep "^$header: extra@address.com" msgtxt3 >to3 &&
1359 + test_line_count = 1 to1 &&
1360 + test_line_count = 1 to2 &&
1361 + test_line_count = 1 to3
1362 +}
1363 +
1364 +test_expect_success $PREREQ 'to-cover adds To to all mail' '
1365 + test_cover_addresses "To" --to-cover
1366 +'
1367 +
1368 +test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1369 + test_cover_addresses "Cc" --cc-cover
1370 +'
1371 +
1372 +test_expect_success $PREREQ 'tocover adds To to all mail' '
1373 + test_config sendemail.tocover true &&
1374 + test_cover_addresses "To"
1375 +'
1376 +
1377 +test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1378 + test_config sendemail.cccover true &&
1379 + test_cover_addresses "Cc"
1380 +'
1381 +
1382 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1383 clean_fake_sendmail &&
1384 echo "alias sbd somebody@example.org" >.mailrc &&