add some basic init tests

This commit is contained in:
Rick Olson 2015-06-28 06:48:59 -06:00
parent e2e04acaf4
commit 7955046d5c
3 changed files with 46 additions and 6 deletions

33
test/test-init.sh Executable file

@ -0,0 +1,33 @@
#!/bin/sh
. "test/testlib.sh"
begin_test "init again"
(
set -e
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
git lfs init
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
)
end_test
begin_test "init with old settings"
(
set -e
git config --global filter.lfs.smudge "git lfs smudge %f"
git config --global filter.lfs.clean "git lfs clean %f"
git lfs init 2> init.log
grep "clean filter should be" init.log
[ "git lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git lfs clean %f" = "$(git config filter.lfs.clean)" ]
)
end_test

@ -124,12 +124,16 @@ setup() {
LFSTEST_URL="$LFS_URL_FILE" LFSTEST_DIR="$REMOTEDIR" lfstest-gitserver > "$REMOTEDIR/gitserver.log" 2>&1 &
mkdir $HOME
git config -f "$HOME/.gitconfig" filter.lfs.required true
git config -f "$HOME/.gitconfig" filter.lfs.smudge "git lfs smudge %f"
git config -f "$HOME/.gitconfig" filter.lfs.clean "git lfs clean %f"
git config -f "$HOME/.gitconfig" credential.helper lfstest
git config -f "$HOME/.gitconfig" user.name "Git LFS Tests"
git config -f "$HOME/.gitconfig" user.email "git-lfs@example.com"
git lfs init
git config --global credential.helper lfstest
git config --global user.name "Git LFS Tests"
git config --global user.email "git-lfs@example.com"
grep "git-lfs clean" "$REMOTEDIR/home/.gitconfig" > /dev/null || {
echo "global git config should be set in $REMOTEDIR/home"
ls -al "$REMOTEDIR/home"
exit 1
}
cp "$HOME/.gitconfig" "$HOME/.gitconfig-backup"
wait_for_file "$LFS_URL_FILE"
}

@ -73,6 +73,9 @@ begin_test () {
err="$TRASHDIR/err"
exec 1>"$out" 2>"$err"
# reset global git config
cp "$HOME/.gitconfig-backup" "$HOME/.gitconfig"
# allow the subshell to exit non-zero without exiting this process
set -x +e
}