git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] trailer: add tests for trailer.trimEmpty
Date: Sat, 07 Feb 2015 14:11:10 +0100	[thread overview]
Message-ID: <20150207131112.394.64847.chriscool@tuxfamily.org> (raw)

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t7513-interpret-trailers.sh | 72 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index bd0ab46..066d00b 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -892,4 +892,76 @@ test_expect_success 'with no command and no key' '
 	test_cmp expected actual
 '
 
+test_expect_success 'with trailer.trimEmpty set to true' '
+	git config trailer.trimEmpty true &&
+	cat >expected <<-EOF &&
+
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" >actual <<-EOF
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to false' '
+	git config trailer.trimEmpty false &&
+	sed -e "s/ Z\$/ /" >expected <<-EOF &&
+
+		review: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" >actual <<-EOF
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to false and a message' '
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		Fixes: Z
+		Acked-by= Z
+		Reviewed-by: Z
+		Signed-off-by: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual &&
+	git interpret-trailers --no-trim-empty --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to 1 and a message' '
+	git config trailer.trimEmpty 1 &&
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
+test_expect_success 'with trailer.trimEmpty set to 1 and --no-trim-empty' '
+	cat complex_message_body >expected &&
+	sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
+		Fixes: Z
+		Acked-by= Z
+		Reviewed-by: Z
+		Signed-off-by: Z
+		sign: A U Thor <author@example.com>
+		Thanks-to: Johannes
+	EOF
+	git interpret-trailers --no-trim-empty --trailer "review:" \
+		--trailer "Thanks-to:Johannes" complex_message >actual
+	test_cmp expected actual
+'
+
 test_done
-- 
2.2.1.313.gcc831f2

                 reply	other threads:[~2015-02-07 13:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150207131112.394.64847.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).