threads / patch / 38520

patch, 3 partstrailer: add tests for trailer.trimEmpty

Subject: [PATCH 2/3] trailer: add tests for trailer.trimEmpty

## tl;dr

One message between Feb 7, 2015 and Feb 7, 2015. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Christian Couder· Feb 7, 2015, 13:11 UTC · lore
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t7513-interpret-trailers.sh | 72 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
Show changes to t/t7513-interpret-trailers.sh +72 −0
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

← back to recent threads