#!/usr/bin/env bash
# Quick Castopod health — bounded network, no hangs.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=lib.sh
source "${ROOT}/lib.sh"

echo "== podman =="
podman ps --filter name=koopa-castopod --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' || true

echo "== local backend :9020 =="
code=$(cp_http_code "http://127.0.0.1:9020/health" || true)
echo "local health → ${code:-000} (307 redirect to public is OK)"

echo "== public =="
# Note: do not put bare @url in curl -w; @ means "read file" in some curl contexts.
for path in "/" "/@foss" "/@foss/feed.xml" "/@foss/episodes/four-freedoms"; do
  url="${CP_BASEURL}${path}"
  code=$(cp_http_code "$url")
  printf '  %s → %s\n' "$url" "$code"
done
