warpgate/tests/02-lifecycle/test-preflight-creates-dirs.sh
grabbit a2d49137f9 Add comprehensive test suite: 63 integration tests + 110 Rust unit tests
Integration tests (tests/):
- 9 categories covering config, lifecycle, signals, supervision,
  cache, writeback, network faults, crash recovery, and CLI
- Shell-based harness with mock NAS (network namespace + SFTP),
  fault injection (tc netem), and power loss simulation
- TAP format runner (run-all.sh) with proper SKIP detection

Rust unit tests (warpgate/src/):
- 110 tests across 14 modules, all passing in 0.01s
- Config parsing, defaults validation, RestartTracker logic,
  RC API response parsing, rclone arg generation, service
  config generation, CLI output formatting, warmup path logic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 11:21:35 +08:00

32 lines
1010 B
Bash
Executable File

#!/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
# Use directories that do not yet exist. Preflight should create them.
NEW_MOUNT="$TEST_DIR/new-mount"
NEW_CACHE="$TEST_DIR/new-cache"
# Ensure they really don't exist
[[ ! -d "$NEW_MOUNT" ]] || { echo "FAIL: $NEW_MOUNT already exists"; exit 1; }
[[ ! -d "$NEW_CACHE" ]] || { echo "FAIL: $NEW_CACHE already exists"; exit 1; }
# Generate config with the non-existent directories.
# No mock NAS is running, so the mount will fail after preflight,
# but that is fine -- we only need to verify directory creation.
gen_config mount_point="$NEW_MOUNT" cache_dir="$NEW_CACHE"
start_warpgate
# Wait for warpgate to exit (it will fail on mount since no NAS is running)
wait_for_exit "$WARPGATE_PID" 35
# Verify preflight created both directories
assert_dir_exists "$NEW_MOUNT"
assert_dir_exists "$NEW_CACHE"
echo "PASS: $(basename "$0" .sh)"