#! /bin/sh
set -e

dir=$(pwd)/debian/tests
. $dir/textutils.sh

frame "Here we are testing the patch" \
      "features/dry-run.patch" \
      "New crontab options -h and -n should be implemented implemented"

echo "================= adding user 'dummy' ====================="
getent passwd dummy || adduser --disabled-password --gecos "" dummy


echo "========== testing that option -h is implemented' ============="

# crontab -h has return code 1, exactly as crontab -foo :(

if su dummy -c "crontab -h" 2>&1 | grep -q "unrecognized option"; then
    abort "-h unrecognised option"
fi

echo "========== testing that option -n is implemented' ============="

echo "* * * * * /bin/ls" > somefile
su dummy -c "crontab -n somefile"
rm somefile



frame "Now we test features/Prompt-on-crontab-deletion.patch"

echo "========== testing that option -i is implemented' ============="

if su dummy -c "crontab -i -r " 2>&1 | grep -q "unrecognized option"; then
    abort "-i unrecognised option"
fi

echo "========== test ok ========================================="

