#!/usr/bin/env bash # Sourced assertion helpers. Tests deliberately use set -u, not set -e: # failing commands are behavior for the harness to inspect. PASS=0 FAIL=0 # check check() { local desc="$1" want="$2" substring="$3" shift 3 local output rc output="$("$@" 2>&1)" rc=$? if [ "$rc" -ne "$want" ]; then echo "FAIL: $desc — exit $rc, wanted $want" printf '%s\n' "$output" | sed 's/^/ /' FAIL=$((FAIL + 1)) return fi if [ -n "$substring" ] && ! printf '%s' "$output" | grep -qF -e "$substring"; then echo "FAIL: $desc — output missing '$substring'" printf '%s\n' "$output" | sed 's/^/ /' FAIL=$((FAIL + 1)) return fi echo "ok: $desc" PASS=$((PASS + 1)) } summary() { printf '%d passed, %d failed\n' "$PASS" "$FAIL" [ "$FAIL" -eq 0 ] } # forge_stub_path — strip the paging parameters the forge shim # injects (#188) so a fixture keyed on the logical endpoint still matches. # The page size moved OUT of the call sites and into the backend, which means # every stub now sees "?per_page=100" appended to a paginated read; without # this, a fixture lookup misses and the stub answers "unreadable", which the # production code correctly reports as a degraded read. forge_stub_path() { printf '%s' "$1" | sed -E 's/([?&])(per_page|limit|page)=[0-9]+/\1/g; s/[?&]+$//; s/([?&])&+/\1/g' }