git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5 2/2] test-config: Add tests for the config_set API

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jul 6, 2014, 18:33 UTC
Message-ID
<vpqzjgm49s8.fsf@anie.imag.fr>
In-Reply-To
<1404631162-18556-3-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 5 quoted lines
> +test_expect_success 'get value for a simple key' '
> +	echo "very blue" >expect &&
> +	test-config get_value core.penguin >actual &&
> +	test_cmp expect actual
> +'
All these tests would greatly benefit from a helper like
test_expect_config () {
	echo "1" >expect &&
	test-config get_value "$2" >actual &&
	test_cmp expect actual
}
Then, all the 3-liners below would become 1-liners.
Should not block inclusion, but may be worth considering.
Show 11 quoted lines
> +test_expect_success 'get value for a key with value as an empty string' '
> +	echo "" >expect &&
> +	test-config get_value core.my >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'get value for a key with value as NULL' '
> +	echo "(NULL)" >expect &&
> +	test-config get_value core.foo >actual &&
> +	test_cmp expect actual
> +'
[...]
Show 9 quoted lines
> +test_expect_success 'key with case sensitive subsection' '
> +	echo "mixed-case" >expect &&
> +	echo "upper-case" >>expect &&
> +	echo "lower-case" >>expect &&
> +	test-config get_value "my.Foo bAr.hi" >actual &&
> +	test-config get_value "my.FOO BAR.hi" >>actual &&
> +	test-config get_value "my.foo bar.hi" >>actual &&
> +	test_cmp expect actual
> +'
This would become a 3-liner with my helper.
Show 9 quoted lines
> +test_expect_success 'key with case insensitive section header' '
> +	echo "ball" >expect &&
> +	echo "ball" >>expect &&
> +	echo "ball" >>expect &&
> +	test-config get_value cores.baz >actual &&
> +	test-config get_value Cores.baz >>actual &&
> +	test-config get_value CORES.baz >>actual &&
> +	test_cmp expect actual
> +'

I think you miss a simple case: get_value with a case that doesn't exist in the config file, like "get_value coreS.baz".

> +test_expect_success 'find value with the highest priority' '
> +	echo hask >expect &&
> +	test-config get_value "core.baz">actual &&
Space before >.
> diff --git a/test-config.c b/test-config.c

No time for a real review of this file, but from a quick look, it seems OK.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tanay AbhraNext: Matthieu Moy
Message 6 of 9 in “git config cache & special querying api utilizing the cache”
  1. 0/3 git config cache & special querying api utilizing the cacheTanay Abhra, Jul 6, 2014
  2. 1/2 add `config_set` API for caching config-like filesTanay Abhra, Jul 6, 2014
  3. Ramsay JonesJul 6, 2014
  4. Matthieu MoyJul 6, 2014
  5. 2/2 test-config: Add tests for the config_set APITanay Abhra, Jul 6, 2014
  6. Matthieu MoyJul 6, 2014
  7. Matthieu MoyJul 6, 2014
  8. Ramkumar RamachandraJul 6, 2014
  9. Matthieu MoyJul 7, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.