Skip to content

Commit a56bb9f

Browse files
committed
Merge branch 'jk/t0303-clean'
Test clean-up. * jk/t0303-clean: t0303: check that helper_test_clean removes all credentials
2 parents 70dadd5 + e41d68b commit a56bb9f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

t/t0303-credential-external.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,24 @@ commands.
3232
. ./test-lib.sh
3333
. "$TEST_DIRECTORY"/lib-credential.sh
3434

35+
# If we're not given a specific external helper to run against,
36+
# there isn't much to test. But we can still run through our
37+
# battery of tests with a fake helper and check that the
38+
# test themselves are self-consistent and clean up after
39+
# themselves.
40+
#
41+
# We'll use the "store" helper, since we can easily inspect
42+
# its state by looking at the on-disk file. But since it doesn't
43+
# implement any caching or expiry logic, we'll cheat and override
44+
# the "check" function to just report all results as OK.
3545
if test -z "$GIT_TEST_CREDENTIAL_HELPER"; then
36-
skip_all="used to test external credential helpers"
37-
test_done
46+
GIT_TEST_CREDENTIAL_HELPER=store
47+
GIT_TEST_CREDENTIAL_HELPER_TIMEOUT=store
48+
check () {
49+
test "$1" = "approve" || return 0
50+
git -c credential.helper=store credential approve
51+
}
52+
check_cleanup=t
3853
fi
3954

4055
test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
@@ -59,4 +74,11 @@ fi
5974
# might be long-term system storage
6075
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
6176

77+
if test "$check_cleanup" = "t"
78+
then
79+
test_expect_success 'test cleanup removes everything' '
80+
test_must_be_empty "$HOME/.git-credentials"
81+
'
82+
fi
83+
6284
test_done

0 commit comments

Comments
 (0)