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

Re: [PATCH 2/2] tests: test credential-store XDG support

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 3, 2015, 22:08 UTC
Message-ID
<vpqegp53f9s.fsf@anie.imag.fr>
In-Reply-To
<1425414299-24000-3-git-send-email-pyokagan@gmail.com>
Paul Tan <pyokagan@gmail.com> writes:
> +# Tests for when $XDG_CONFIG_HOME/git/credentials exists but
> +# ~/.git-credentials does not.

As much as possible, put text in the $1 of test_expect_success instead of comments.

> +rm "$HOME/.git-credentials"
> +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/git"
> +echo '' > "${XDG_CONFIG_HOME:-$HOME/.config}/git/credentials"
> +helper_test store

Don't write code outside test_expect_success (read "Do's, don'ts & things to keep in mind" in t/README).

> +test_expect_success '~/.git-credentials will not be created if XDG git-credentials exist' '
> +	test ! -e "$HOME/.git-credentials"
> +'
test_path_is_missing (see test-lib-functions.sh)
> +echo '' > "$HOME/.git-credentials"
> +echo '' > "${XDG_CONFIG_HOME:-$HOME/.config}/git/credentials"
Not even that outside test_expect_success ;-).
Also, no space after > (Documentation/CodingGuidelines).
Show 10 quoted lines
> +test_expect_success 'Credentials are stored in XDG file if both XDG and HOME files exist' '
> +	check approve store <<-\EOF
> +	protocol=https
> +	host=example.com
> +	username=store-user
> +	password=store-pass
> +	EOF
> +	read contents < "${XDG_CONFIG_HOME:-$HOME/.config}/git/credentials"
> +	test ! -z "$contents"
> +	read contents < "$HOME/.git-credentials"
No space after <.
> +	test -z "$contents"
> +'
> +test_expect_success 'Credentials from XDG file are used if the
> +	credentials exist in both XDG and HOME files' '
Blank line between tests please.
Show 10 quoted lines
> +test_expect_success 'Credentials from both XDG and HOME files meeting the criteria are erased' '
> +	check reject $HELPER <<-\EOF &&
> +	protocol=https
> +	host=example.com
> +	EOF
> +	read contents < "${XDG_CONFIG_HOME:-$HOME/.config}/git/credentials"
> +	test -z "$contents"
> +	read contents < "$HOME/.git-credentials"
> +	test -z "$contents"
> +'
I'd rather do stg like

echo >expected test_cmp expected "${XDG_CONFIG_HOME:-$HOME/.config}/git/credentials" test_cmp expected $HOME/.git-credentials

so that a test failure shows a diagnosis.
Regards,
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Paul TanNext: Junio C Hamano
Message 10 of 11 in “[GSoC15] git-credentials-store: support XDG config dir”
  1. [GSoC15] git-credentials-store: support XDG config dirPaul Tan, Mar 3, 2015
  2. 1/2 git-credential-store: support XDG config dirPaul Tan, Mar 3, 2015
  3. Matthieu MoyMar 3, 2015
  4. Junio C HamanoMar 3, 2015
  5. Jeff KingMar 4, 2015
  6. Paul TanMar 5, 2015
  7. Junio C HamanoMar 5, 2015
  8. Matthieu MoyMar 6, 2015
  9. 2/2 tests: test credential-store XDG supportPaul Tan, Mar 3, 2015
  10. Matthieu MoyMar 3, 2015
  11. Junio C HamanoMar 3, 2015

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.