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

set -euo pipefail

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

setup "$1"
plan 4

# force replace symlink
echo "original" > "$TESTDIR/replace-target"
echo "newtarget" > "$TESTDIR/new-target"
ln -s "$TESTDIR/replace-target" "$TESTDIR/force-link"
write_conf "L+ $TESTDIR/force-link - - - - $TESTDIR/new-target"
run_test "force replace symlink command" "$SEEDFILES" --create "$TESTDIR/conf"
assert_symlink_to "$TESTDIR/force-link" "$TESTDIR/new-target"

# truncate file
echo "old content" > "$TESTDIR/trunc-file"
write_conf "F $TESTDIR/trunc-file 0644 - - - new content"
run_test "truncate file command" "$SEEDFILES" --create "$TESTDIR/conf"
assert_file_equals "$TESTDIR/trunc-file" "new content"

done_testing
