#!/bin/sh

. "`dirname \"$0\"`/common.sh"

USER="mailto:paul.boddie@example.com"
SENDER="mailto:resource-room-confroom@example.com"
FBFILE="$STORE/$USER/freebusy"
FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER"

mkdir -p "$PREFS/$USER"
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
echo 'share' > "$PREFS/$USER/freebusy_sharing"

  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-publish.txt" 2>> $ERROR \
| "$SHOWMAIL" \
> out0.tmp

   grep -q "^20140401T070000Z${TAB}20140401T080000Z" "$FBOTHERFILE" \
&& grep -q "^20140401T080000Z${TAB}20140401T100000Z" "$FBOTHERFILE" \
&& echo "Success" \
|| echo "Failed"

  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-publish-again.txt" 2>> $ERROR \
| "$SHOWMAIL" \
> out0.tmp

   grep -q "^20140401T070000Z${TAB}20140401T080000Z" "$FBOTHERFILE" \
&& ! grep -q "^20140401T080000Z${TAB}20140401T100000Z" "$FBOTHERFILE" \
&& grep -q "^20140401T083000Z${TAB}20140401T100000Z" "$FBOTHERFILE" \
&& echo "Success" \
|| echo "Failed"
