#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" source "$SCRIPT_DIR/../harness/helpers.sh" setup_test_env trap teardown_test_env EXIT TARGET="$TEST_DIR/existing.toml" # Pre-create a file at the target path so config-init would overwrite it. echo "# pre-existing config" > "$TARGET" # config-init should refuse to overwrite an existing file. output=$("$WARPGATE_BIN" config-init --output "$TARGET" 2>&1) && { echo "FAIL: config-init should have exited non-zero for existing file" echo " output: $output" exit 1 } # The error message must mention that the file already exists. assert_output_contains "$output" "already exists" # The original file should be untouched. assert_file_content "$TARGET" "# pre-existing config" echo "PASS: $(basename "$0" .sh)"