mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 07:54:15 +00:00
more tests
This commit is contained in:
44
tests-ng/update-ignore.sh
vendored
44
tests-ng/update-ignore.sh
vendored
@@ -29,25 +29,38 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sg
|
|||||||
# $2 path
|
# $2 path
|
||||||
grep_or_fail()
|
grep_or_fail()
|
||||||
{
|
{
|
||||||
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern not found in ${2}" && exit 1)
|
grep "${1}" "${2}" >/dev/null 2>&1 || (echo "pattern \"${1}\" not found in ${2}" && exit 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
# dotdrop directory
|
# dotdrop directory
|
||||||
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
dt="${tmps}/dotfiles"
|
|
||||||
mkdir -p "${dt}"
|
|
||||||
mkdir -p "${dt}"/a/{b,c}
|
|
||||||
echo 'a' > "${dt}"/a/b/abfile
|
|
||||||
echo 'a' > "${dt}"/a/c/acfile
|
|
||||||
|
|
||||||
# fs dotfiles
|
# fs dotfiles
|
||||||
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
|
||||||
|
dt="${tmps}/dotfiles"
|
||||||
|
mkdir -p "${dt}"
|
||||||
|
|
||||||
|
# dotfiles in dotdrop
|
||||||
|
mkdir -p "${dt}"/a/{b,c,x}
|
||||||
|
echo 'a' > "${dt}"/a/b/abfile
|
||||||
|
echo 'a' > "${dt}"/a/c/acfile
|
||||||
|
echo 'a' > "${dt}"/a/x/xfile
|
||||||
|
|
||||||
|
cp -r "${dt}"/a "${tmpd}"/
|
||||||
|
|
||||||
|
mkdir -p "${dt}"/a/be-gone
|
||||||
|
echo 'a' > "${dt}"/a/be-gone/file
|
||||||
|
|
||||||
|
# filesystem files
|
||||||
|
touch "${tmpd}"/a/newfile
|
||||||
|
echo 'b' > "${tmpd}"/a/c/acfile
|
||||||
|
mkdir -p "${tmpd}"/a/newdir/b
|
||||||
|
touch "${tmpd}"/a/newdir/b/c
|
||||||
|
mkdir -p "${tmpd}"/a/x
|
||||||
|
echo "b" > "${tmpd}"/a/x/xfile
|
||||||
|
|
||||||
clear_on_exit "${tmps}"
|
clear_on_exit "${tmps}"
|
||||||
clear_on_exit "${tmpd}"
|
clear_on_exit "${tmpd}"
|
||||||
|
|
||||||
cp -r "${dt}"/a "${tmpd}"/
|
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
cat > "${cfg}" << _EOF
|
cat > "${cfg}" << _EOF
|
||||||
@@ -63,21 +76,12 @@ dotfiles:
|
|||||||
- "*/cfile"
|
- "*/cfile"
|
||||||
- "*/newfile"
|
- "*/newfile"
|
||||||
- "*/newdir"
|
- "*/newdir"
|
||||||
|
- "*/x/**"
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
|
||||||
|
|
||||||
#tree ${dt}
|
|
||||||
|
|
||||||
# edit/add files
|
|
||||||
echo "[+] edit/add files"
|
|
||||||
touch "${tmpd}"/a/newfile
|
|
||||||
echo 'b' > "${tmpd}"/a/c/acfile
|
|
||||||
mkdir -p "${tmpd}"/a/newdir/b
|
|
||||||
touch "${tmpd}"/a/newdir/b/c
|
|
||||||
|
|
||||||
# update
|
# update
|
||||||
echo "[+] update"
|
echo "[+] update"
|
||||||
@@ -85,7 +89,9 @@ cd "${ddpath}" | ${bin} update -f -c "${cfg}" --verbose --profile=p1 --key f_abc
|
|||||||
|
|
||||||
# check files haven't been updated
|
# check files haven't been updated
|
||||||
grep_or_fail 'b' "${dt}/a/c/acfile"
|
grep_or_fail 'b' "${dt}/a/c/acfile"
|
||||||
|
grep_or_fail 'a' "${dt}/a/x/xfile"
|
||||||
[ -e "${dt}"/a/newfile ] && echo "should not have been updated" && exit 1
|
[ -e "${dt}"/a/newfile ] && echo "should not have been updated" && exit 1
|
||||||
|
[ -d "${dt}"/a/be-gone ] && echo "should have been removed" && exit 1
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user