add test and doc for stats, make test send_message more stable

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-01 15:04:37 +02:00
parent 2a66ee928f
commit 8e7583d3b7
6 changed files with 26 additions and 12 deletions

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$$ v0.96-dev-7-g0153928
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -74,14 +74,21 @@ Start or Stop your Bot use the following commands:
./bashbot.sh kill
```
### User count
### User stats
deprecated, will be removed!
To count the total number of users and messages run the following command:
```
./bashbot.sh stats
```
### Sending broadcasts to all users
To send a broadcast to all of users that ever used the bot run the following command:
```
./bashbot.sh broadcast "Hey! I just wanted to let you know that the bot's been updated!"
```
deprecated, will be removed!
----
@ -246,5 +253,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.96-dev3-0-gdddd1ce
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.96-dev3-0-gdddd1ce
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -32,7 +32,7 @@ trap exit 1 EXIT
cd "${TESTDIR}" || exit
echo "Test if $JSONSHFILE exists ..."
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} Fail diff ${file}!"; exit 1; }
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} json.sh not found"; exit 1; }
echo "Test Sourcing of bashbot.sh ..."
# shellcheck source=./bashbot.sh
@ -44,6 +44,7 @@ trap '' EXIT
cd "${DIRME}" || exit 1
echo "${SUCCESS}"
echo "Test bashbot.sh count"
echo "Test bashbot.sh stat"
cp "${REFDIR}/count.test" "${TESTDIR}/count.jssh"
"${TESTDIR}/bashbot.sh" count
"${TESTDIR}/bashbot.sh" stats >"${TESTDIR}/stats.out"
diff -q "${TESTDIR}/stats.out" "${REFDIR}/stats.out" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff stats output!"; FAIL="1"; }

View File

@ -0,0 +1 @@
A total of 272 messages from 24 users are processed.

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.96-dev-7-g0153928
#### $$VERSION$$ v0.96-dev3-1-g2a66ee9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -54,7 +54,12 @@ done < "${INPUTFILE}" 2>>"${LOGFILE}"
echo " done."
{ diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1; } | cat -v
sort -d -o "${OUTPUTFILE}.sort" "${OUTPUTFILE}"
sort -d -o "${REFFILE}.sort" "${REFFILE}"
{ diff -c "${REFFILE}.sort" "${OUTPUTFILE}.sort" || exit 1; } | cat -v
rm -f "${REFFILE}.sort"
echo " ... all \"send_message\" functions seems to work as expected."
echo "${SUCCESS}"

View File

@ -1 +1 @@
bashbottestscript
123456789:BASHBOTTESTSCRIPTbashbottestscript_