diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/README | 7 | ||||
-rwxr-xr-x | tests/test_calendar-cli.sh | 29 | ||||
-rwxr-xr-x | tests/tests.sh (renamed from tests/script_test.sh) | 22 |
3 files changed, 49 insertions, 9 deletions
diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..406ea8e --- /dev/null +++ b/tests/README @@ -0,0 +1,7 @@ +TL;DR: run test_calendar-cli.sh, don't run tests.sh. + +Probably we should add some standard python test code here that can be run through nose or tox, but after all this is a command line utility - hence I found it appropriate to start with functional tests written to be executed from through a shell. + +The file tests.sh will run towards whatever calendar server is configured in .config/calendar.conf, and it has potential side effects, it will wipe out any prior events within the time range 2010-10-10 and 2010-10-14. + +The file test_calendar-cli.sh will set up a radicale calendar server, run the tests.sh towards radicale, then set up xandikos and run tests.sh towards xandikos. diff --git a/tests/test_calendar-cli.sh b/tests/test_calendar-cli.sh new file mode 100755 index 0000000..be2717e --- /dev/null +++ b/tests/test_calendar-cli.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +######################################################################## +## RADICALE +######################################################################## +storage=$(mktemp -d) +python3 -m radicale --storage-filesystem-folder=$storage & +sleep 0.3 +jobs -l +radicale_pid=$(jobs -l | perl -ne '/^\[\d+\]\+\s+(\d+)\s+Running/ && print $1') +if [ -n "$radicale_pid" ] +then + echo "## Radicale now running on pid $radicale_pid" + calendar_cli="../calendar-cli --caldav-url=http://localhost:5232/ --caldav-user=testuser --calendar-url=/testuser/calendar-cli-test-calendar" + $calendar_cli calendar create calendar-cli-test-calendar + export calendar_cli + ./tests.sh + kill $radicale_pid + rm -rf $storage +else + echo "## Could not start up radicale (is it installed?). Will skip running tests towards radicale" +fi + + +######################################################################## +## XANDIKOS +######################################################################## +## TODO! work in progress + diff --git a/tests/script_test.sh b/tests/tests.sh index 3a3f91a..d496d8a 100755 --- a/tests/script_test.sh +++ b/tests/tests.sh @@ -1,20 +1,18 @@ #!/bin/bash -## Sorry - I have no idea how much of this script is compatible with -## POSIX shell and how much is bashisms ... been using bash for too -## long. - set -e +######################################################################## ## SETUP +######################################################################## error() { echo "$1" exit 255 } -[ -x ./calendar-cli.py ] && calendar_cli=./calendar-cli.py -[ -x ../calendar-cli.py ] && calendar_cli=../calendar-cli.py +[ -z "$calendar_cli" ] && [ -x ./calendar-cli.py ] && calendar_cli=./calendar-cli.py +[ -z "$calendar_cli" ] && [ -x ../calendar-cli.py ] && calendar_cli=../calendar-cli.py [ -z "$calendar_cli" ] && error "couldn't find ./calendar_cli.py nor ../calendar_cli.py" calendar_cli() { @@ -28,7 +26,9 @@ calendar_cli() { for uid in $($calendar_cli calendar agenda --from-time=2010-10-10 --agenda-days=4 --event-template='{uid}') ; do calendar_cli calendar delete --event-uid=$uid ; done calendar_cli todo --categories scripttest delete -## TESTING +######################################################################## +## TEST CODE FOLLOWS +######################################################################## ## EVENTS @@ -36,12 +36,16 @@ echo "## testing $calendar_cli" echo "## this is a very simple test script without advanced error handling" echo "## if this test script doesn't output 'all tests completed' in the end, something went wrong" -echo "## Attempting to add a past event at 2010-10-09 20:00:00, 2 hours duration" +echo "## Attempting to add an event at 2010-10-09 20:00:00, 2 hours duration" calendar_cli calendar add '2010-10-09 20:00:00+2h' 'testing testing' uid=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') -echo "## Attempting to add a past event at 2010-10-10 20:00:00, CET (1 hour duration is default)" +[ -n "$uid" ] || error "got no UID back" + +echo "## Attempting to add an event at 2010-10-10 20:00:00, CET (1 hour duration is default), with description and non-ascii location" calendar_cli calendar add '2010-10-10 20:00:00+01:00' 'testing testing' --set-description='this is a test calendar event' --set-location='Москва' uid2=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') +[ -n "$uid2" ] || error "got no UID back" + echo "## Attempting to add a past event at 2010-10-11 20:00:00, CET, 3h duration" calendar_cli calendar add '2010-10-11 20:00:00+01:00+3h' 'testing testing' uid3=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') |