diff mbox series

[v2,2/7] t1300: add test for --replace-all with value_regex

Message ID 829d0ccd8c6ae52e78eda52b15283867a0be673e.1606147507.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series config: add --fixed-value option | expand

Commit Message

Derrick Stolee Nov. 23, 2020, 4:05 p.m. UTC
From: Derrick Stolee <dstolee@microsoft.com>

The --replace-all option was added in 4ddba79d (git-config-set: add more
options) but was not tested along with the 'value_regex' parameter.
Since we will be updating this option to optionally treat 'value_regex'
as a fixed string, let's add a test here that documents the current
behavior.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 t/t1300-config.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Emily Shaffer Nov. 23, 2020, 7:40 p.m. UTC | #1
On Mon, Nov 23, 2020 at 04:05:02PM +0000, Derrick Stolee via GitGitGadget wrote:
> 
> 
> The --replace-all option was added in 4ddba79d (git-config-set: add more
> options) but was not tested along with the 'value_regex' parameter.
> Since we will be updating this option to optionally treat 'value_regex'
> as a fixed string, let's add a test here that documents the current
> behavior.

I like the commit message and the diff a lot. Concise and complete,
explains when the problem came from. I don't think it even needs the
rationale about adding more options later - there's missing test
coverage and you're adding it. But it's useful to reviewers and a handy
step on the journey of this topic.

> 
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Emily Shaffer <emilyshaffer@google.com>
diff mbox series

Patch

diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 19836ec83b..8783767d4f 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1946,4 +1946,18 @@  test_expect_success 'set all config with value_regex' '
 	test_cmp expect actual
 '
 
+test_expect_success '--replace-all and value_regex' '
+	rm -f config &&
+	git config --file=config --add abc.key one &&
+	git config --file=config --add abc.key two &&
+	git config --file=config --add abc.key three &&
+	git config --file=config --replace-all abc.key four "o+" &&
+	git config --file=config --list >actual &&
+	cat >expect <<-\EOF &&
+	abc.key=four
+	abc.key=three
+	EOF
+	test_cmp expect actual
+'
+
 test_done