#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" source "$SCRIPT_DIR/../harness/helpers.sh" source "$SCRIPT_DIR/../harness/mock-nas.sh" # Test: write_back=0s causes immediate upload — no dirty files linger. # With zero write-back delay, rclone should upload files as soon as they # are closed, so the dirty count should reach 0 quickly. require_root setup_test_env trap teardown_test_env EXIT start_mock_nas # Zero write-back delay — files are uploaded immediately gen_config write_back=0s start_warpgate wait_for_mount wait_for_rc_api # Write a file through the FUSE mount echo "instant-wb" > "$TEST_MOUNT/instant.txt" # Give time for the immediate write-back to complete sleep 5 # Dirty count should be 0 — the file was already uploaded dirty=$(get_dirty_count) if [[ "$dirty" -ne 0 ]]; then echo "FAIL: expected dirty count 0 with write_back=0s, got $dirty" >&2 exit 1 fi # Verify the file arrived on the NAS with correct content assert_file_content "$NAS_ROOT/instant.txt" "instant-wb" echo "PASS: $(basename "$0" .sh)"