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>
67 lines
2.5 KiB
Bash
Executable File
67 lines
2.5 KiB
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
|
|
|
|
# Generate a minimal config — only required fields are set.
|
|
# The binary should fill in all other fields with defaults.
|
|
source "$HARNESS_DIR/config-gen.sh"
|
|
_gen_minimal_config
|
|
|
|
# Verify the binary accepts the minimal config without complaint.
|
|
# This proves that defaults are applied for every non-required field.
|
|
output=$("$WARPGATE_BIN" status -c "$TEST_CONFIG" 2>&1) || {
|
|
echo "FAIL: warpgate status exited non-zero; defaults should fill in"
|
|
echo " output: $output"
|
|
exit 1
|
|
}
|
|
|
|
# The minimal config intentionally omits these fields (all should be
|
|
# filled by compiled-in defaults matching the PRD):
|
|
# sftp_port = 22
|
|
# sftp_connections = 8
|
|
# max_size = "200G"
|
|
# max_age = "720h"
|
|
# min_free = "10G"
|
|
# chunk_size = "256M"
|
|
# write_back = "5s"
|
|
# transfers = 4
|
|
# enable_smb = true
|
|
# enable_nfs = false
|
|
# mount.point = "/mnt/nas-photos"
|
|
#
|
|
# We cannot easily extract the in-memory defaults from the binary, but a
|
|
# successful status invocation on a minimal config is proof that every
|
|
# default was applied without error.
|
|
|
|
# Double-check the config file does NOT contain the fields that should
|
|
# come from defaults — confirming we are truly testing the defaults path.
|
|
assert_output_not_contains "$(cat "$TEST_CONFIG")" "sftp_port"
|
|
assert_output_not_contains "$(cat "$TEST_CONFIG")" "max_size"
|
|
assert_output_not_contains "$(cat "$TEST_CONFIG")" "enable_smb"
|
|
assert_output_not_contains "$(cat "$TEST_CONFIG")" "transfers"
|
|
|
|
# Parse the status output for actual applied defaults and verify key
|
|
# values match the PRD specifications.
|
|
assert_output_contains "$output" "sftp_port"
|
|
assert_output_contains "$output" "22"
|
|
assert_output_contains "$output" "sftp_connections"
|
|
assert_output_contains "$output" "8"
|
|
assert_output_contains "$output" "write_back"
|
|
assert_output_contains "$output" "5s"
|
|
assert_output_contains "$output" "enable_smb"
|
|
assert_output_contains "$output" "true"
|
|
assert_output_contains "$output" "enable_nfs"
|
|
assert_output_contains "$output" "false"
|
|
assert_output_contains "$output" "enable_webdav"
|
|
assert_output_contains "$output" "false"
|
|
assert_output_contains "$output" "dir_cache_time"
|
|
assert_output_contains "$output" "5m0s"
|
|
assert_output_contains "$output" "transfers"
|
|
assert_output_contains "$output" "4"
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|