#!/bin/sh
set -e

if [ -z "$TMPDIR" ]; then
  TMPDIR=/tmp/adt
  rm -rf $TMPDIR
  mkdir -p $TMPDIR
fi

export XDG_CACHE_HOME=$TMPDIR/cache
export PASSPHRASE=test

cp -r /bin $TMPDIR/source
duplicity full $TMPDIR/source u1+http://duplicity-test
rm -r $XDG_CACHE_HOME
duplicity u1+http://duplicity-test $TMPDIR/restore
diff -p $TMPDIR/source $TMPDIR/restore

echo "PASSED"
