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>
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: `warpgate cache-list` shows cached files via vfs/list RC API
|
|
#
|
|
# Creates test files on the mock NAS, reads them through the FUSE mount to
|
|
# populate the cache, then verifies that `cache-list` reports them.
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "$SCRIPT_DIR/../harness/helpers.sh"
|
|
source "$SCRIPT_DIR/../harness/mock-nas.sh"
|
|
|
|
require_root
|
|
setup_test_env
|
|
trap teardown_test_env EXIT
|
|
|
|
# Start mock NAS and place test files on it
|
|
start_mock_nas
|
|
nas_create_file "photos/IMG_0001.cr3" 64
|
|
nas_create_file "photos/IMG_0002.cr3" 64
|
|
nas_create_file "documents/notes.txt" 1
|
|
|
|
# Generate config pointing at mock NAS
|
|
gen_config
|
|
|
|
# Start warpgate and wait for readiness
|
|
start_warpgate
|
|
wait_for_mount 60
|
|
wait_for_rc_api 30
|
|
|
|
# Read files through the FUSE mount to pull them into cache
|
|
cat "$TEST_MOUNT/photos/IMG_0001.cr3" > /dev/null
|
|
cat "$TEST_MOUNT/photos/IMG_0002.cr3" > /dev/null
|
|
cat "$TEST_MOUNT/documents/notes.txt" > /dev/null
|
|
|
|
# Run cache-list
|
|
output=$(run_warpgate_cmd cache-list)
|
|
|
|
# Verify output contains file names
|
|
assert_output_contains "$output" "IMG_0001"
|
|
assert_output_contains "$output" "IMG_0002"
|
|
assert_output_contains "$output" "notes"
|
|
|
|
# Verify output also contains size values alongside file names.
|
|
# The 64 KB files should show as "64" or "65536" or "64.0" etc.
|
|
if echo "$output" | grep -qE "[0-9]"; then
|
|
true
|
|
else
|
|
echo "FAIL: cache-list output does not contain any size values" >&2
|
|
echo " output: $output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Verify a size-like value appears on the same line as a file name
|
|
if echo "$output" | grep -i "IMG_0001" | grep -qE "[0-9]"; then
|
|
true
|
|
else
|
|
echo "FAIL: cache-list does not show size alongside file names" >&2
|
|
echo " output: $output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|