1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 00:34:16 +00:00

add tests cleaning

This commit is contained in:
deadc0de6
2021-10-19 22:18:39 +02:00
parent f9c318679a
commit f4cff17f1b
110 changed files with 413 additions and 355 deletions

View File

@@ -45,11 +45,6 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
# this is the test
################################################################
clean()
{
rm -rf ${tmps} ${tmpd} ~/.dotdrop-test
}
# the dotfile source
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
mkdir -p ${tmps}/dotfiles
@@ -57,6 +52,10 @@ mkdir -p ${tmps}/dotfiles
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
#echo "dotfile destination: ${tmpd}"
clear_on_exit "${tmps}"
clear_on_exit "${tmpd}"
clear_on_exit "~/.dotdrop-test"
# create the dotfile
echo "original" > ${tmpd}/testfile
@@ -79,11 +78,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
cat ${cfg}
# ensure exists and is not link
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
# re-import without changing
echo "[+] re-import without changes"
@@ -91,11 +90,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
cat ${cfg}
# test is only once
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
# re-import with changes
echo "[+] re-import with changes"
@@ -104,11 +103,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
cat ${cfg}
# test is only once
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
grep 'modified' ${tmps}/dotfiles/${tmpd}/testfile
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
# ###################################################
@@ -119,11 +118,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
cat ${cfg}
# ensure exists and is not link
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
grep 'original' ${tmps}/dotfiles/dotdrop.test
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
# re-import without changing
echo "[+] re-import without changes in home"
@@ -131,11 +130,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
cat ${cfg}
# test is only once
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
grep 'original' ${tmps}/dotfiles/dotdrop.test
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
# re-import with changes
echo "[+] re-import with changes in home"
@@ -144,14 +143,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
cat ${cfg}
# test is only once
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
grep 'modified' ${tmps}/dotfiles/dotdrop.test
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
## CLEANING
clean
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
echo "OK"
exit 0