mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-04-08 07:31:49 +00:00
adjust remaing tests
This commit is contained in:
parent
63b9c283a2
commit
9f5f061c22
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-pre2-10-gae4610a
|
||||
#### $$VERSION$$ v0.98-pre2-18-g3a51b51
|
||||
|
||||
# common variables
|
||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||
@ -26,10 +26,12 @@ export SUCCESS NOSUCCESS
|
||||
NOSUCCESS=" FAILED!"
|
||||
|
||||
# default input, reference and output files
|
||||
export INPUTFILE REFFILE OUTPUTFILE
|
||||
export INPUTFILE REFFILE INPUTFILE2 REFFILE2 OUTPUTFILE
|
||||
OUTPUTFILE="${TESTDIR}/${REFDIR}.out"
|
||||
INPUTFILE="${DIRME}/${REFDIR}/${REFDIR}.input"
|
||||
REFFILE="${DIRME}/${REFDIR}/${REFDIR}.result"
|
||||
OUTPUTFILE="${TESTDIR}/${REFDIR}.out"
|
||||
INPUTFILE2="${DIRME}/${REFDIR}/${REFDIR}2.input"
|
||||
REFFILE2="${DIRME}/${REFDIR}/${REFDIR}2.result"
|
||||
|
||||
# do not query telegram when testing
|
||||
export BASHBOT_URL TESTTOKEN
|
||||
@ -54,7 +56,8 @@ compare_sorted() {
|
||||
sort -d -o "${1}.sort" "${1}"
|
||||
sort -d -o "${2}.sort" "${2}"
|
||||
diff -c "${1}.sort" "${2}.sort" || ret=1
|
||||
rm -f "${1}.sort" "${2}.sort"
|
||||
[[ "${1}" != "${TESTDIR}"* ]] && rm -f "${1}"
|
||||
[[ "${2}" != "${TESTDIR}"* ]] && rm -f "${2}"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-pre2-10-gae4610a
|
||||
#### $$VERSION$$ v0.98-pre2-18-g3a51b51
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
@ -20,23 +20,40 @@ get_file() {
|
||||
}
|
||||
|
||||
# get telegram input from file
|
||||
export UPDATE UPD
|
||||
UPDATE="$(cat "${INPUTFILE}")"
|
||||
declare -A UPD
|
||||
source <( printf 'UPD=( %s )' "$(sed <<<"${UPDATE}" -E -e 's/\t/=/g' -e 's/=(true|false)/="\1"/')" )
|
||||
export UPDATE
|
||||
declare -Ax UPD
|
||||
|
||||
# run process_message
|
||||
echo "Check process_message ..."
|
||||
# run process_message --------------
|
||||
ARRAYS="USER CHAT REPLYTO FORWARD URLS CONTACT CAPTION LOCATION MESSAGE VENUE SERVICE"
|
||||
|
||||
echo "Check process_message regular message..."
|
||||
|
||||
UPDATE="$(< "${INPUTFILE}")"
|
||||
Json2Array 'UPD' <"${INPUTFILE}"
|
||||
set -x
|
||||
{ process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
||||
echo "Compare results"
|
||||
|
||||
USER[ID]="123456789"
|
||||
CHAT[ID]="123456789"
|
||||
{ pre_process_message "0"; process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
||||
USER[ID]="123456789"; CHAT[ID]="123456789"
|
||||
|
||||
# output processed input
|
||||
print_array "USER" "CHAT" "REPLYTO" "FORWARD" "URLS" "CONTACT" "CAPTION" "LOCATION" "MESSAGE" "VENUE" "SERVICE">"${OUTPUTFILE}"
|
||||
# shellcheck disable=SC2086
|
||||
print_array ${ARRAYS} >"${OUTPUTFILE}"
|
||||
compare_sorted "${REFFILE}" "${OUTPUTFILE}" || exit 1
|
||||
|
||||
# run process_message ------------
|
||||
echo "Check process_message service message..."
|
||||
|
||||
UPDATE="$(cat "${INPUTFILE2}")"
|
||||
Json2Array 'UPD' <"${INPUTFILE2}"
|
||||
set -x
|
||||
{ pre_process_message "0"; process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
||||
USER[ID]="123456789"; CHAT[ID]="123456789"
|
||||
|
||||
# output processed input
|
||||
# shellcheck disable=SC2086
|
||||
print_array ${ARRAYS} >"${OUTPUTFILE}"
|
||||
compare_sorted "${REFFILE2}" "${OUTPUTFILE}" || exit 1
|
||||
|
||||
|
||||
echo "${SUCCESS}"
|
||||
|
||||
cd "${DIRME}" || exit 1
|
||||
|
@ -89,16 +89,3 @@
|
||||
["result",0,"message","voice","duration"] 2
|
||||
["result",0,"message","voice","mime_type"] "audio/ogg"
|
||||
["result",0,"message","voice","file_size"] 4262
|
||||
["result",0,"message","new_chat_participant","id"] 123456789
|
||||
["result",0,"message","new_chat_participant","is_bot"] false
|
||||
["result",0,"message","new_chat_participant","first_name"] "Kay"
|
||||
["result",0,"message","new_chat_participant","last_name"] "M"
|
||||
["result",0,"message","new_chat_member","id"] 123456789
|
||||
["result",0,"message","new_chat_member","is_bot"] false
|
||||
["result",0,"message","new_chat_member","first_name"] "Kay"
|
||||
["result",0,"message","new_chat_member","last_name"] "M"
|
||||
["result",0,"message","new_chat_members",0,"id"] 123456789
|
||||
["result",0,"message","new_chat_members",0,"is_bot"] false
|
||||
["result",0,"message","new_chat_members",0,"first_name"] "Kay"
|
||||
["result",0,"message","new_chat_members",0,"last_name"] "M"
|
||||
["result",0,"message","left_chat_member","id"] 123456789
|
||||
|
@ -41,9 +41,3 @@ VENUE: FOURSQUARE 4c4321afce54e21eee980d1a
|
||||
VENUE: LATITUDE 49.631824
|
||||
VENUE: LONGITUDE 8.377072
|
||||
VENUE: TITLE Kolb's Biergarten
|
||||
SERVICE: 0 yes
|
||||
SERVICE: LEFTMEMBER 123456789
|
||||
SERVICE: NEWMEMBER 123456789
|
||||
SERVICE: NEWPHOTO
|
||||
SERVICE: NEWTITLE
|
||||
SERVICE: PINNED
|
||||
|
13
test/d-process_message-test/d-process_message-test2.input
Normal file
13
test/d-process_message-test/d-process_message-test2.input
Normal file
@ -0,0 +1,13 @@
|
||||
["result",0,"message","new_chat_participant","id"] 123456789
|
||||
["result",0,"message","new_chat_participant","is_bot"] false
|
||||
["result",0,"message","new_chat_participant","first_name"] "Kay"
|
||||
["result",0,"message","new_chat_participant","last_name"] "M"
|
||||
["result",0,"message","new_chat_member","id"] 123456789
|
||||
["result",0,"message","new_chat_member","is_bot"] false
|
||||
["result",0,"message","new_chat_member","first_name"] "Kay"
|
||||
["result",0,"message","new_chat_member","last_name"] "M"
|
||||
["result",0,"message","new_chat_members",0,"id"] 123456789
|
||||
["result",0,"message","new_chat_members",0,"is_bot"] false
|
||||
["result",0,"message","new_chat_members",0,"first_name"] "Kay"
|
||||
["result",0,"message","new_chat_members",0,"last_name"] "M"
|
||||
["result",0,"message","left_chat_member","id"] 123456789
|
22
test/d-process_message-test/d-process_message-test2.result
Normal file
22
test/d-process_message-test/d-process_message-test2.result
Normal file
@ -0,0 +1,22 @@
|
||||
USER: FIRST_NAME
|
||||
USER: ID 123456789
|
||||
USER: LAST_NAME
|
||||
USER: USERNAME
|
||||
CHAT: ALL_ADMIN
|
||||
CHAT: FIRST_NAME
|
||||
CHAT: ID 123456789
|
||||
CHAT: LAST_NAME
|
||||
CHAT: TITLE
|
||||
CHAT: TYPE
|
||||
CHAT: USERNAME
|
||||
CAPTION: 0
|
||||
LOCATION: LATITUDE
|
||||
LOCATION: LONGITUDE
|
||||
MESSAGE: 0 /_new_chat_member 123456789 Kay M
|
||||
MESSAGE: ID
|
||||
SERVICE: 0 yes
|
||||
SERVICE: LEFTMEMBER 123456789
|
||||
SERVICE: NEWMEMBER 123456789
|
||||
SERVICE: NEWPHOTO
|
||||
SERVICE: NEWTITLE
|
||||
SERVICE: PINNED
|
@ -2,7 +2,9 @@ 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\nwith 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"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#### $$VERSION$$ v0.98-pre2-18-g3a51b51
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
@ -33,7 +33,7 @@ cp ${TESTDIR}/*commands.sh "${BASHBOT_ETC}" || exit 1
|
||||
set -f
|
||||
cp -r "${TESTDIR}/bashbot.sh" "${TESTDIR}/modules" "${BASHBOT_BIN}" || exit 1
|
||||
|
||||
TESTFILES="${TOKENFILE} ${ACLFILE} ${ADMINFILE}"
|
||||
TESTFILES="${TOKENFILE} ${ACLFILE}"
|
||||
|
||||
|
||||
echo "Check first run in ENVIRONMENT ..."
|
||||
|
1
test/e-env-test/blocked.jssh
Normal file
1
test/e-env-test/blocked.jssh
Normal file
@ -0,0 +1 @@
|
||||
["blocked_user_or_chat_id"] "name and reason"
|
3
test/e-env-test/botconfig.jssh
Normal file
3
test/e-env-test/botconfig.jssh
Normal file
@ -0,0 +1,3 @@
|
||||
["bot_config_key"] "config_key_value"
|
||||
["bottoken"] "123456789:BASHBOTTESTSCRIPTbashbottestscript_"
|
||||
["botadmin"] "?"
|
1
test/e-env-test/count.jssh
Normal file
1
test/e-env-test/count.jssh
Normal file
@ -0,0 +1 @@
|
||||
["counted_user_chat_id"] "num_messages_seen"
|
Loading…
x
Reference in New Issue
Block a user