summaryrefslogtreecommitdiffstats
path: root/karm/test/webdav.sh
blob: 8d51db92c82cb5563d93ad45681ce26440b375c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

# Add a todo to an iCal file stored on a webdav server.

exec >>check.log 2>&1

source __lib.sh

# check for required perl stuff
perl -e "use Net::DAV::Server;" > /dev/null 2>&1
if ! [ $? = 0 ]; then
	echo "PASS"
	exit 0
fi

# Start webdav server
perl __webdav.pl &
sleep 2
WEBDAV_PID=`ps -C "perl __webdav.pl" -o pid=`

# Start karm
TESTFILE="http://localhost:4242/testkarm.ics"
TESTFILE_LOCAL="/tmp/testkarm.ics"
TESTTODO="testtodo"
SKIP_TESTFILE_DELETE=true
# Need this or karm complains there is no file
rm -f $TESTFILE_LOCAL
touch $TESTFILE_LOCAL
set_up
#wait till download is ready
sleep 3

# add a todo
dcop $DCOPID KarmDCOPIface addTask "$TESTTODO"
sleep 1
dcop $DCOPID KarmDCOPIface save

sleep 1

if grep $TESTTODO $TESTFILE_LOCAL
	then RVAL=0
	else RVAL=1
fi

# clean up
tear_down
#if [ -e $TESTFILE_LOCAL ]; then rm $TESTFILE_LOCAL; fi
if [ -n $WEBDAV_PID ]; then kill $WEBDAV_PID; fi

# return 0 on success, 1 on failure
if [ $RVAL -eq 0 ]
then 
  echo "PASS $0"
  exit 0
else 
  echo "FAIL $0"
  exit 1
fi