2019-04-19 15:31:01 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-01-02 15:00:59 +00:00
|
|
|
#===============================================================================
|
|
|
|
#
|
|
|
|
# FILE: c-init-test.sh
|
|
|
|
#
|
|
|
|
# USAGE: must run only from dev/all-tests.sh
|
|
|
|
#
|
|
|
|
# DESCRIPTION: test "bashbot.sh init" and sourcing bashbot.sh
|
|
|
|
#
|
|
|
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
|
|
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
|
|
|
#
|
2021-03-04 12:58:04 +00:00
|
|
|
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
2021-01-02 15:00:59 +00:00
|
|
|
#===============================================================================
|
2019-04-19 15:31:01 +00:00
|
|
|
|
2019-04-21 09:34:17 +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
|
|
|
|
2020-06-01 11:44:30 +00:00
|
|
|
TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${BLOCKEDFILE} ${ADMINFILE}"
|
2019-04-19 17:24:30 +00:00
|
|
|
|
2021-01-01 23:32:32 +00:00
|
|
|
#set -e
|
2019-04-19 15:31:01 +00:00
|
|
|
|
|
|
|
# run bashbot first time with init
|
2021-01-02 15:00:59 +00:00
|
|
|
printf "Run bashbot init ...\n"
|
2019-04-20 19:09:36 +00:00
|
|
|
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
|
2021-01-05 11:06:22 +00:00
|
|
|
${TESTTOKEN}
|
2019-04-19 15:31:01 +00:00
|
|
|
nobody
|
|
|
|
botadmin
|
2020-12-04 20:35:21 +00:00
|
|
|
|
2019-04-19 15:31:01 +00:00
|
|
|
EOF
|
2021-01-02 15:00:59 +00:00
|
|
|
printf "%s\n" "${SUCCESS}"
|
2019-04-19 17:24:30 +00:00
|
|
|
|
2020-06-23 14:35:50 +00:00
|
|
|
# compare files with reference files
|
2021-01-02 15:00:59 +00:00
|
|
|
printf "Check new files after init ...\n"
|
2019-04-20 19:31:05 +00:00
|
|
|
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}"
|
2021-01-02 15:00:59 +00:00
|
|
|
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}" || { printf "%s\n" "${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}"
|
2021-01-02 15:00:59 +00:00
|
|
|
printf "%s\n" "${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
|
|
|
|
2021-01-02 15:00:59 +00:00
|
|
|
printf "%s\n" "Test if ${JSONSHFILE} exists ..."
|
2021-01-05 11:06:22 +00:00
|
|
|
[ ! -x "${JSONSHFILE}" ] && { printf "%s\n" "${NOSUCCESS} json.sh not found"; exit 1; }
|
2019-05-16 09:23:27 +00:00
|
|
|
|
2021-01-02 15:18:15 +00:00
|
|
|
printf "Test Sourcing of bashbot.sh ...\n"
|
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
|
2021-01-02 15:00:59 +00:00
|
|
|
|
|
|
|
printf "Test Sourcing of commands.sh ...\n"
|
2019-05-13 09:24:42 +00:00
|
|
|
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
|
2021-01-02 15:00:59 +00:00
|
|
|
|
|
|
|
printf "%s\n" "${SUCCESS}"
|
2019-04-20 19:09:36 +00:00
|
|
|
|