#!/bin/sh
set -e

. `dirname $0`/assert.sh

ORIG_TZ=`grep -v '^#' /etc/timezone`
echo "original tz: $ORIG_TZ"

# should activate daemon and work
assert_in "Local time:" "`timedatectl --no-pager`"

# change timezone
assert_eq "`timedatectl --no-pager set-timezone Europe/Moscow 2>&1`" ""
assert_eq "`cat /etc/timezone`" "Europe/Moscow"
assert_in "Time.*zone: Europe/Moscow (MSK, +" "`timedatectl --no-pager`"

# reset timezone to original
assert_eq "`timedatectl  --no-pager set-timezone $ORIG_TZ 2>&1`" ""
assert_eq "`cat /etc/timezone`" "$ORIG_TZ"
