Skip to contentSkip to conversation

tests: Deduplicate code in send-email test

PATCH New Christian Ludwig 1 participant 1 message Jan 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: Deduplicate code in send-email test

Use the wrapper function around the sed statement like everywhere else in the test. Unfortunately the wrapper function is defined pretty late.

Move the wrapper to the top of the test file, so future users have it available right away.

---
 t/t9001-send-email.sh | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
t/t9001-send-email.sh +7 -10
index 4d261c2a9..81869d891 100755
@@ -6,6 +6,12 @@ test_description='git send-email'
 # May be altered later in the test
 PREREQ="PERL"
 
+replace_variable_fields () {
+	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
+		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
+}
+
 test_expect_success $PREREQ 'prepare reference tree' '
 	echo "1A quick brown fox jumps over the" >file &&
 	echo "lazy dog" >>file &&
@@ -296,10 +302,7 @@ test_expect_success $PREREQ 'Show all headers' '
 		[email protected] \
 		--in-reply-to="<[email protected]>" \
 		--smtp-server relay.example.com \
-		$patches |
-	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
-		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
-		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+		$patches | replace_variable_fields \
 		>actual-show-all-headers &&
 	test_cmp expected-show-all-headers actual-show-all-headers
 '
@@ -554,12 +557,6 @@ Result: OK
 EOF
 "
 
-replace_variable_fields () {
-	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
-		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
-		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
-}
-
 test_suppression () {
 	git send-email \
 		--dry-run \
Signature · 1 line
2.15.1