adjust tests to changed behavior

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-27 18:31:35 +02:00
parent a656533693
commit 2dafbd9d63
8 changed files with 19 additions and 23 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.98-pre2-0-ga597303
#### $$VERSION$$ v0.98-pre2-8-ga656533
# common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
@ -12,11 +12,11 @@ export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
# common filenames
export TOKENFILE ACLFILE COUNTFILE BLOCKEDFILE ADMINFILE DATADIR JSONSHFILE
TOKENFILE="token"
TOKENFILE="botconfig.jssh"
ACLFILE="botacl"
COUNTFILE="count.jssh"
BLOCKEDFILE="blocked.jssh"
ADMINFILE="botadmin"
ADMINFILE="botconfig.jssh"
DATADIR="data-bot-bash"
JSONSHFILE="JSON.sh/JSON.sh"

View File

@ -1 +0,0 @@
?

View File

@ -0,0 +1,3 @@
["bot_config_key"] "config_key_value"
["bottoken"] "123456789:BASHBOTTESTSCRIPTbashbottestscript_"
["botadmin"] "?"

View File

@ -1 +0,0 @@
123456789:BASHBOTTESTSCRIPTbashbottestscript_

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.98-pre2-0-ga597303
#### $$VERSION$$ v0.98-pre2-8-ga656533
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -29,6 +29,7 @@ source <( printf 'UPD=( %s )' "$(sed <<<"${UPDATE}" -E -e 's/\t/=/g' -e 's/=(tru
echo "Check process_message ..."
set -x
{ process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
echo "Compare results"
USER[ID]="123456789"
CHAT[ID]="123456789"

View File

@ -3,7 +3,6 @@ USER: ID 123456789
USER: LAST_NAME M
USER: USERNAME Gnadelwartz
CHAT: ALL_ADMIN
CHAT: ALL_MEMBERS_ARE_ADMINISTRATORS
CHAT: FIRST_NAME Test
CHAT: ID 123456789
CHAT: LAST_NAME Bot
@ -46,5 +45,5 @@ SERVICE: 0 yes
SERVICE: LEFTMEMBER 123456789
SERVICE: NEWMEMBER 123456789
SERVICE: NEWPHOTO
SERVICE: NEWTILE
SERVICE: NEWTITLE
SERVICE: PINNED

View File

@ -2,24 +2,19 @@ chat:123456 JSON:"text":"\# test for text only output"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":"This is a normal text"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":"This is a normal text
with a line break"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":" This is a <b>HTML<\/b> text","parse_mode":"html"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":" This is a <b>HTML<\/b> text
with a line break","parse_mode":"html"
chat:123456 JSON:"text":" This is a <b>HTML<\/b> text\nwith a line break","parse_mode":"html"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":" This is a \*MARKDOWN\* text","parse_mode":"markdown"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":" This is a \*MARKDOWN\* text
with a line break","parse_mode":"markdown"
chat:123456 JSON:"text":" This is a \*MARKDOWN\* text\nwith a line break","parse_mode":"markdown"
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":"\# test for keyboard\, file\, venue output"
@ -40,11 +35,7 @@ URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?12345
chat:123456 JSON:"text":"Text plus keyboard will appear in chat", "reply_markup": {"inline_keyboard": [ [ {"text":"Button Text", "url":"https://www..."}] ]}
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":"STABILO 88\/240 Fineliner point 88
[https:\/\/images\-na\.ssl\-images\-amazon\.com\/images\/I\/41oypA3kmHL\.l_SX300\.jpg]
second part of text
plus newline\.", "reply_markup": {"inline_keyboard": [ [ {"text":"Bei Amazon ansehen \.\.\.", "url":"https://www.amazon.de/dp/B014TN3JYW"}] ]}
chat:123456 JSON:"text":"STABILO 88\/240 Fineliner point 88\n\n[https:\/\/images\-na\.ssl\-images\-amazon\.com\/images\/I\/41oypA3kmHL\.l_SX300\.jpg]\nsecond part of text\nplus newline\.", "reply_markup": {"inline_keyboard": [ [ {"text":"Bei Amazon ansehen \.\.\.", "url":"https://www.amazon.de/dp/B014TN3JYW"}] ]}
URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage
chat:123456 JSON:"text":"\# test for sendfile"

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.98-pre2-0-ga597303
#### $$VERSION$$ v0.98-pre2-8-ga656533
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -21,13 +21,17 @@ source "${TESTDIR}/commands.sh" source
# first user asking for botadmin will botadmin
echo "Check \"user_is_botadmin\" ..."
echo '?' >"${ADMINFILE}" # auto mode
printf '["botadmin"] "?"\n' >>"${ADMINFILE}" # auto mode
echo "BOTADMIN ..."
user_is_botadmin "BOTADMIN" || exit 1 # should never fail
echo "NOBOTADMIN ..."
user_is_botadmin "NOBOTADMIN" && exit 1 # should fail
echo "BOTADMIN ..."
user_is_botadmin "BOTADMIN" || exit 1 # same name as first one, should work
if [ "$(cat "${ADMINFILE}")" = "BOTADMIN" ]; then
echo "Check config file ..."
if [ "$(getConfigKey "botadmin")" = "BOTADMIN" ]; then
echo " ... \"user_is_botadmin\" seems to work as expected."
else
exit 1