warpgate/tests/09-cli/test-status-not-running.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

38 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Test: `warpgate status` when warpgate is NOT running shows DOWN
#
# Verifies that `status` exits 0 and reports a down/not-mounted state when
# no warpgate daemon is running. The status command should never crash
# even when the RC API is unavailable.
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 config but do NOT start warpgate
gen_config
# Run the status subcommand — must not fail
exit_code=0
output=$(run_warpgate_cmd status) || exit_code=$?
# Verify exit code is 0 (status always succeeds, even when mount is down)
if [[ "$exit_code" -ne 0 ]]; then
echo "FAIL: status exited with code $exit_code (expected 0)" >&2
echo " output: $output" >&2
exit 1
fi
# Verify output indicates the mount is not active
if echo "$output" | grep -qi "DOWN\|not active\|not mounted"; then
true
else
echo "FAIL: status output does not indicate mount is down" >&2
echo " output: $output" >&2
exit 1
fi
echo "PASS: $(basename "$0" .sh)"