[PATCH v2 08/10] replace: add tests for --edit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 t/t6050-replace.sh | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 719a116..7609174 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -318,6 +318,35 @@ test_expect_success 'test --format long' '
 	test_cmp expected actual
 '
 
+test_expect_success 'setup a fake editor' '
+	cat >fakeeditor <<-\EOF &&
+		#!/bin/sh
+		sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
+		mv "$1.new" "$1"
+	EOF
+	chmod +x fakeeditor
+'
+
+test_expect_success '--edit with and without already replaced object' '
+	GIT_EDITOR=./fakeeditor test_must_fail git replace --edit "$PARA3" &&
+	GIT_EDITOR=./fakeeditor git replace --force --edit "$PARA3" &&
+	git replace -l | grep "$PARA3" &&
+	git cat-file commit "$PARA3" | grep "A fake Thor" &&
+	git replace -d "$PARA3" &&
+	GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
+	git replace -l | grep "$PARA3" &&
+	git cat-file commit "$PARA3" | grep "A fake Thor"
+'
+
+test_expect_success '--edit and change nothing or command failed' '
+	git replace -d "$PARA3" &&
+	GIT_EDITOR=true test_must_fail git replace --edit "$PARA3" &&
+	GIT_EDITOR="./fakeeditor;false" test_must_fail git replace --edit "$PARA3" &&
+	GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
+	git replace -l | grep "$PARA3" &&
+	git cat-file commit "$PARA3" | grep "A fake Thor"
+'
+
 test_expect_success 'replace ref cleanup' '
 	test -n "$(git replace)" &&
 	git replace -d $(git replace) &&
-- 
1.9.rc0.17.g651113e


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]