#!/bin/sh
set -e

TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT

torf --version
torf --help > /dev/null

mkdir -p "$TMPDIR/content"
printf 'hello world\n' > "$TMPDIR/content/file1.txt"
printf 'more data\n'   > "$TMPDIR/content/file2.txt"

torf "$TMPDIR/content" -o "$TMPDIR/test.torrent" --nodate --nomagnet
torf -i "$TMPDIR/test.torrent" | grep -q '^Name'

torf -i "$TMPDIR/test.torrent" "$TMPDIR/content"

torf -i "$TMPDIR/test.torrent" \
    -c 'autopkgtest comment' \
    -o "$TMPDIR/edited.torrent"
torf -i "$TMPDIR/edited.torrent" | grep -q 'autopkgtest comment'

echo "All smoke tests passed"
