telegram-bot-bash/test/c-init-test.sh

51 lines
1.2 KiB
Bash
Raw Normal View History

2019-04-19 15:31:01 +00:00
#!/usr/bin/env bash
2019-05-18 18:25:18 +00:00
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
2019-04-19 15:31:01 +00:00
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
source "./ALL-tests.inc.sh"
2019-04-20 19:09:36 +00:00
TESTTOKEN="bashbottestscript"
TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${ADMINFILE}"
2019-04-19 17:24:30 +00:00
2019-04-19 15:31:01 +00:00
set -e
# run bashbot first time with init
2019-04-20 19:09:36 +00:00
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
2019-04-19 17:24:30 +00:00
$TESTTOKEN
2019-04-19 15:31:01 +00:00
nobody
botadmin
EOF
echo "${SUCCESS}"
2019-04-19 17:24:30 +00:00
2019-04-20 19:09:36 +00:00
# compare files with refrence files
2019-04-20 19:31:05 +00:00
echo "Check new files after init ..."
export FAIL="0"
2019-04-20 19:09:36 +00:00
for file in ${TESTFILES}
2019-04-19 17:24:30 +00:00
do
2019-04-20 19:09:36 +00:00
ls -d "${TESTDIR}/${file}" >>"${LOGFILE}"
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; }
2019-04-19 17:24:30 +00:00
done
2019-04-20 19:31:05 +00:00
[ "${FAIL}" != "0" ] && exit "${FAIL}"
echo "${SUCCESS}"
2019-04-19 17:24:30 +00:00
2019-04-20 14:26:16 +00:00
trap exit 1 EXIT
2019-04-20 19:09:36 +00:00
cd "${TESTDIR}" || exit
2019-04-20 14:26:16 +00:00
echo "Test if $JSONSHFILE exists ..."
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} Fail diff ${file}!"; exit 1; }
echo "Test Sourcing of bashbot.sh ..."
2019-04-20 14:26:16 +00:00
# shellcheck source=./bashbot.sh
2019-04-20 19:09:36 +00:00
source "${TESTDIR}/bashbot.sh" source
source "${TESTDIR}/commands.sh" source
2019-04-20 14:26:16 +00:00
trap '' EXIT
2019-04-20 19:09:36 +00:00
cd "${DIRME}" || exit 1
echo "${SUCCESS}"
2019-04-20 19:09:36 +00:00
echo "Test bashbot.sh count"
cp "${REFDIR}/count.test" "${TESTDIR}/count"
"${TESTDIR}/bashbot.sh" count
2019-04-20 19:31:05 +00:00