#!/usr/bin/env bash # Test: warmup --newer-than filters files by modification time # # Verifies that warmup with --newer-than only caches files modified # within the specified window, skipping older files. This maps to # rclone lsf --max-age under the hood. 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 start_mock_nas # Create an old file (timestamp: 2023-01-01) and a new file (now) nas_create_file_content "old.txt" "old-content" touch -t 202301010000 "$NAS_ROOT/old.txt" nas_create_file_content "new.txt" "new-content" # Generate default config gen_config # Start warpgate and wait for readiness start_warpgate wait_for_mount wait_for_rc_api # Run warmup with --newer-than 7d (only files modified in last 7 days) run_warpgate_cmd warmup --newer-than 7d "" # Verify the new file is cached assert_cached "new.txt" # Verify the old file is NOT cached (older than 7 days) assert_not_cached "old.txt" echo "PASS: $(basename "$0" .sh)"