some more init tests

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-04-20 21:09:36 +02:00
parent 7512681d64
commit 31834194ad
26 changed files with 53 additions and 49 deletions

View File

@ -102,4 +102,4 @@ Bashbot is not more (in)secure as any other Bot written in any other language, w
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -166,5 +166,5 @@ That's it!
If you feel that there's something missing or if you found a bug, feel
free to submit a pull request!
latexmath:[\[VERSION\]] 0.70-dev-16-g2eac362
latexmath:[\[VERSION\]] 0.70-dev-18-g7512681
++++++++++++++++++++++++++++++++++++++++++++

View File

@ -1,7 +1,7 @@
#!/bin/sh
# description: Start or stop telegram-bash-bot
#
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# shellcheck disable=SC2009
# shellcheck disable=SC2181

View File

@ -10,7 +10,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
#
# Exit Codes:
# - 0 sucess (hopefully)

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# shellcheck disable=SC2016
#
# Easy Versioning in git:

View File

@ -61,5 +61,5 @@ group. This step is up to you actually.
#### [Next Getting started](2_usage.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -159,5 +159,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -156,5 +156,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker"
#### [Prev Advanced Usage](3_advanced.md)
#### [Next Expert Use](4_expert.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
#### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -112,5 +112,5 @@ The second warning is about an unused variable, this is true because in our exam
#### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -348,5 +348,5 @@ Send Input from Telegram to waiting Interactive Chat.
#### [Prev Best Practice](5_practice.md)
#### [Next Developer Rules](7_develop.md)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -63,5 +63,5 @@ fi
#### [Prev Function Reference](6_function.md)
#### $$VERSION$$ 0.70-dev-17-gb1aef7d
#### $$VERSION$$ 0.70-dev-18-g7512681

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
SHELL=/bin/sh

View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ 0.70-dev-16-g2eac362
#### $$VERSION$$ 0.70-dev-18-g7512681
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ 0.70-dev-17-gb1aef7d
#### $$VERSION$$ 0.70-dev-18-g7512681
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
@ -11,8 +11,7 @@ cd "${GIT_DIR}/.." || exit 1
# create test environment
TESTENV="/tmp/bashbot.test$$"
cp -r . "${TESTENV}"
#cd "${TESTENV}" || exit 1
cd "test" || exit 1
#set -e
fail=0
@ -20,7 +19,7 @@ tests=0
passed=0
#all_tests=${__dirname:}
#echo PLAN ${#all_tests}
for test in $(find test/*-test.sh | sort -u) ;
for test in $(find ./*-test.sh | sort -u) ;
do
[ "${test}" = "test/all-tests.sh" ] && continue
[ ! -x "${test}" ] && continue

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ 0.70-dev-17-gb1aef7d
#### $$VERSION$$ 0.70-dev-18-g7512681
dev/hooks/pre-commit.sh
../dev/hooks/pre-commit.sh

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#### $$VERSION$$ 0.70-dev-17-gb1aef7d
#### $$VERSION$$ 0.70-dev-18-g7512681
dev/hooks/pre-push.sh
../dev/hooks/pre-push.sh

View File

@ -1,10 +1,16 @@
#!/usr/bin/env bash
#### $$VERSION$$ 0.70-dev-17-gb1aef7d
#### $$VERSION$$ 0.70-dev-18-g7512681
TOKENFILE="./token"
TESTTOKEN="bashbottestscript"
TESTME="$(basename "$0")"
NEWFILES="${TOKENFILE} botacl count botadmin JSON.sh/JSON.sh tmp-bot-bash"
DIRME="$(pwd)"
TESTDIR="$1"
LOGFILE="${TESTDIR}/${TESTME}.log"
REFDIR="${TESTME%.sh}"
TOKENFILE="token"
TESTTOKEN="bashbottestscript"
TESTFILES="${TOKENFILE} botacl count botadmin"
set -e
@ -12,40 +18,39 @@ set -e
echo "Running bashbot init"
echo "............................"
# change to test env
[ "$1" = "" ] && echo "not called from testsuite, exit" && exit
cd "$1" || exit 1
[ "${TESTDIR}" = "" ] && echo "not called from testsuite, exit" && exit
unset IFS; set -f
# run bashbot first time with init
export TERM=""
"${1}/bashbot.sh" init >"${TESTME}.log" <<EOF
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
$TESTTOKEN
nobody
botadmin
EOF
echo "OK"
# files must exsit after init
# compare files with refrence files
echo "Check check new files ..."
for file in ${NEWFILES}
for file in ${TESTFILES}
do
ls -d "${file}" >/dev/null
ls -d "${TESTDIR}/${file}" >>"${LOGFILE}"
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}"
done
echo "OK"
echo "Check value of token ..."
if [ "${TESTTOKEN}" = "$(cat "${TOKENFILE}")" ]; then
echo "OK"
else
echo "Token not correct or not written!"
exit 1
fi
echo "Test Sourcing of bashbot.sh ..."
trap exit 1 EXIT
cd "${TESTDIR}" || exit
# shellcheck source=./bashbot.sh
source "$1/bashbot.sh" source
source "${TESTDIR}/bashbot.sh" source
trap '' EXIT
cd "${DIRME}" || exit 1
echo "Test bashbot.sh count"
cp "${REFDIR}/count.test" "${TESTDIR}/count"
"${TESTDIR}/bashbot.sh" count