Fix PR10: Gcm_input may loose its input message
[gnucomo.git] / test / notification_sendmail
diff --git a/test/notification_sendmail b/test/notification_sendmail
new file mode 100755 (executable)
index 0000000..bc83495
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+#
+#  Test the log processing of gcm_daemon
+#  Create a database with one object and read a piece of sendmail log
+#
+#  This tests problem report nrs. 14 through 17
+
+
+rm -f gcm_input.log
+createdb gnucomo_test
+
+result=0
+
+if psql gnucomo_test -q <../src/database/create.sql >/dev/null
+then
+   #  Prepare the database
+
+   psql gnucomo_test -q -c "insert into object (objectname) values ('schiza.andromeda.nl')"
+
+   #  read logs for both objects
+
+   ../src/gcm_input/gcm_input -c gnucomo_test -h schiza.andromeda.nl -d 'oct 26 2003 20:30:45' <log0010
+
+   # Test gcm_daemon
+   cd ../src/gcm_daemon; ./gcm_daemon.php -c gnucomo_test; cd ../../test
+
+   # Check the notifications.
+
+   NR_NOTIF1=`psql gnucomo_test -q -t -c "select count(*) from notification"`
+   if [[ $NR_NOTIF1 -ne 4 ]]
+   then
+      echo "$NR_NOTIF1 notifications for object 1 (4 expected)."
+      result=2
+   fi
+
+   #  Clean up.
+
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+
+   dropdb gnucomo_test
+   exit $result
+else
+   echo Can not create test database
+   dropdb gnucomo_test
+   exit 1
+fi