summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/_setup_alias16
-rwxr-xr-xtests/test_calendar-cli.sh6
-rwxr-xr-xtests/tests.sh24
3 files changed, 41 insertions, 5 deletions
diff --git a/tests/_setup_alias b/tests/_setup_alias
index 45a267c..0d5c302 100644
--- a/tests/_setup_alias
+++ b/tests/_setup_alias
@@ -1,3 +1,5 @@
+outfile=$(mktemp)
+
error() {
echo "$1"
echo "sleeping 3"
@@ -9,10 +11,18 @@ error() {
[ -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"
+[ -z "$kal" ] && [ -x ./cal.py ] && kal=./cal.py
+[ -z "$kal" ] && [ -x ../cal.py ] && kal=../cal.py
+[ -z "$kal" ] && error "couldn't find ./cal.py nor ../cal.py"
+
calendar_cli() {
echo " $calendar_cli $@"
- output=$($calendar_cli "$@")
- [ -z "$output" ] || echo $output
+ output=$($calendar_cli "$@" | tee $outfile)
+ [ -z "$output" ] || [ -z "$QUIET" ] || echo $output
}
-## TODO: new kal command aka cal.py \ No newline at end of file
+kal() {
+ echo " $kal $@"
+ output=$($kal "$@" | tee $outfile)
+ [ -z "$output" ] || [ -z "$QUIET" ] || echo $output
+}
diff --git a/tests/test_calendar-cli.sh b/tests/test_calendar-cli.sh
index 6d22973..c2eae03 100755
--- a/tests/test_calendar-cli.sh
+++ b/tests/test_calendar-cli.sh
@@ -11,7 +11,7 @@ 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-cli.py --caldav-url=http://localhost:5232/ --caldav-user=testuser --calendar-url=/testuser/calendar-cli-test-calendar"
kal="../cal.py --caldav-url=http://localhost:5232/ --caldav-user=testuser --calendar-url=/testuser/calendar-cli-test-calendar"
echo "## Creating a calendar"
$calendar_cli calendar create calendar-cli-test-calendar
@@ -20,7 +20,9 @@ then
## the calendar is created. Without the statement above, I'll
## just get 404 when running tests.
export calendar_cli
+ export kal
./tests.sh
+ sleep 600
kill $radicale_pid
sleep 0.3
else
@@ -43,7 +45,9 @@ if [ -n "$xandikos_pid" ]
then
echo "## Xandikos now running on pid $xandikos_pid"
calendar_cli="../calendar-cli --caldav-url=http://localhost:8080/ --caldav-user=user"
+ kal="../cal.py --caldav-url=http://localhost:8080/ --caldav-user=user"
export calendar_cli
+ export kal
./tests.sh
kill $xandikos_pid
else
diff --git a/tests/tests.sh b/tests/tests.sh
index f519447..a71f8b5 100755
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -9,13 +9,15 @@ set -e
for path in . .. ./tests ../tests
do
setup="$path/_setup_alias"
- [ -x $setup ] && source $setup
+ [ -f $setup ] && source $setup
done
echo "## CLEANUP from earlier failed test runs"
+QUIET=true
for uid in $($calendar_cli calendar agenda --from-time=2010-10-09 --agenda-days=5 --event-template='{uid}') ; do calendar_cli calendar delete --event-uid=$uid ; done
calendar_cli todo --categories scripttest delete
+unset QUIET
########################################################################
## TEST CODE FOLLOWS
@@ -65,11 +67,27 @@ uid=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
echo "## fetching the full day event, in ics format"
calendar_cli --icalendar calendar agenda --from-time=2010-10-13 --agenda-days=1
+
echo "$output" | grep -q "whole day" || error "could not find the event"
echo "$output" | grep -q "20101010" || error "could not find the date"
echo "$output" | grep -q "20101010T" && error "a supposed whole day event was found to be with the time of day"
echo "OK: found the event"
+## saving the ics data
+tmpfile=$(mktemp)
+cat $outfile > $tmpfile
+
+echo "## cleanup, delete it"
+calendar_cli calendar delete --event-uid=$uid
+
+echo "## Same, using kal add ics"
+kal add ical --ical-file=$tmpfile
+#rm $tmpfile
+calendar_cli --icalendar calendar agenda --from-time=2010-10-13 --agenda-days=1
+echo "$output" | grep -q "whole day" || error "could not find the event"
+echo "$output" | grep -q "20101010" || error "could not find the date"
+echo "$output" | grep -q "20101010T" && error "a supposed whole day event was found to be with the time of day"
+echo "OK: found the event"
echo "## cleanup, delete it"
calendar_cli calendar delete --event-uid=$uid
@@ -177,3 +195,7 @@ calendar_cli todo --hide-parents --categories scripttest list
[ -z "$output" ] && echo "## OK: found no tasks now"
echo "## ALL TESTS COMPLETED! YAY!"
+
+
+rm $outfile
+