Skip to content

Commit 8ccc4e4

Browse files
mstsirkingitster
authored andcommitted
test/send-email: to-cover, cc-cover tests
Add tests for the new feature. Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f515c90 commit 8ccc4e4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

t/t9001-send-email.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,51 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' '
13341334
test -n "$(ls msgtxt*)"
13351335
'
13361336

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: [email protected]\nFrom:/" cover-to-edit.patch >"$cover" &&
1346+
git send-email \
1347+
--force \
1348+
--from="Example <[email protected]>" \
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: [email protected]" msgtxt1 >to1 &&
1357+
grep "^$header: [email protected]" msgtxt2 >to2 &&
1358+
grep "^$header: [email protected]" 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+
13371382
test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
13381383
clean_fake_sendmail &&
13391384
echo "alias sbd [email protected]" >.mailrc &&

0 commit comments

Comments
 (0)