t/t-[un]install.sh: add and refine scope checks

As the checks for local and global LFS configurations in our
install and uninstall tests of the --local option vary somewhat
in their breadth and their use of dummy text strings, we attempt
to make them more consistent and complete before adding any tests
for the new --worktree option.

To bring additional consistency we add an uninstall test
which confirms that using --local outside a repository fails,
akin to the existing installation test of that case.

And we also add matching install and uninstall tests to confirm
the expected error message when conflicting --local and --system
scope options are both supplied.
This commit is contained in:
Chris Darroch 2020-06-16 12:25:51 -07:00
parent fbfd474eb1
commit 7e779b8442
2 changed files with 77 additions and 4 deletions

@ -210,19 +210,27 @@ begin_test "install --local"
set -e
# old values that should be ignored by `install --local`
git config --global filter.lfs.smudge "git lfs smudge %f"
git config --global filter.lfs.clean "git lfs clean %f"
git config --global filter.lfs.smudge "global smudge"
git config --global filter.lfs.clean "global clean"
git config --global filter.lfs.process "global filter"
mkdir install-local-repo
cd install-local-repo
git init
git lfs install --local
# local configs are correct
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs smudge -- %f" = "$(git config --local filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs clean -- %f" = "$(git config --local filter.lfs.clean)" ]
[ "git lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
[ "git-lfs filter-process" = "$(git config --local filter.lfs.process)" ]
# global configs
[ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
[ "global clean" = "$(git config --global filter.lfs.clean)" ]
[ "global filter" = "$(git config --global filter.lfs.process)" ]
)
end_test
@ -278,6 +286,25 @@ begin_test "install --local outside repository"
)
end_test
begin_test "install --local with conflicting scope"
(
set -e
reponame="$(basename "$0" ".sh")-scope-conflict"
mkdir "$reponame"
cd "$reponame"
git init
set +e
git lfs install --local --system 2>err.log
res=$?
set -e
[ "Only one of --local and --system options can be specified." = "$(cat err.log)" ]
[ "0" != "$res" ]
)
end_test
begin_test "install in directory without access to .git/lfs"
(
set -e

@ -86,7 +86,6 @@ begin_test "uninstall inside repository with --skip-repo"
)
end_test
begin_test "uninstall inside repository with default pre-push hook"
(
set -e
@ -174,6 +173,47 @@ begin_test "uninstall hooks inside repository"
)
end_test
begin_test "uninstall --local outside repository"
(
set -e
# If run inside the git-lfs source dir this will update its .git/config & cause issues
if [ "$GIT_LFS_TEST_DIR" == "" ]; then
echo "Skipping uninstall --local because GIT_LFS_TEST_DIR is not set"
exit 0
fi
has_test_dir || exit 0
set +e
git lfs uninstall --local >out.log
res=$?
set -e
[ "Not in a git repository." = "$(cat out.log)" ]
[ "0" != "$res" ]
)
end_test
begin_test "uninstall --local with conflicting scope"
(
set -e
reponame="$(basename "$0" ".sh")-scope-conflict"
mkdir "$reponame"
cd "$reponame"
git init
set +e
git lfs uninstall --local --system 2>err.log
res=$?
set -e
[ "Only one of --local and --system options can be specified." = "$(cat err.log)" ]
[ "0" != "$res" ]
)
end_test
begin_test "uninstall --local"
(
set -e
@ -190,8 +230,11 @@ begin_test "uninstall --local"
git lfs install --local
# local configs are correct
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs smudge -- %f" = "$(git config --local filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs clean -- %f" = "$(git config --local filter.lfs.clean)" ]
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
[ "git-lfs filter-process" = "$(git config --local filter.lfs.process)" ]
# global configs
@ -207,8 +250,11 @@ begin_test "uninstall --local"
grep -v "Global Git LFS configuration has been removed." uninstall.log
# global configs
[ "global smudge" = "$(git config filter.lfs.smudge)" ]
[ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
[ "global clean" = "$(git config filter.lfs.clean)" ]
[ "global clean" = "$(git config --global filter.lfs.clean)" ]
[ "global filter" = "$(git config filter.lfs.process)" ]
[ "global filter" = "$(git config --global filter.lfs.process)" ]
# local configs are empty