#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-or-later

set -euo pipefail

. "$(dirname "$0")/lib.sh"

setup "$1"
plan 6

# combined create and remove
mkdir -p "$TESTDIR/combo-rm"
touch "$TESTDIR/combo-rm/old-file"
write_conf \
    "d $TESTDIR/combo-new 0755 - - -" \
    "R $TESTDIR/combo-rm"
run_test "combined create remove command" "$SEEDFILES" --create --remove "$TESTDIR/conf"
assert_exists "$TESTDIR/combo-new"
assert_not_exists "$TESTDIR/combo-rm"

# idempotent create
write_conf "d $TESTDIR/idempotent 0755 - - -"
run_test "idempotent first create" "$SEEDFILES" --create "$TESTDIR/conf"
run_test "idempotent second create" "$SEEDFILES" --create "$TESTDIR/conf"
assert_exists "$TESTDIR/idempotent"

done_testing
