From 1164640a08dffde93f1516275f0d880aa389a71a Mon Sep 17 00:00:00 2001 From: codex-bot-andresmgsl Date: Mon, 24 Aug 2026 18:01:04 +0000 Subject: [PATCH] test: close exhaustive pagination review gaps --- lib/forge-forgejo.sh | 5 +++++ test/forge-backends.test.sh | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/forge-forgejo.sh b/lib/forge-forgejo.sh index 247c760..20deffe 100644 --- a/lib/forge-forgejo.sh +++ b/lib/forge-forgejo.sh @@ -109,6 +109,11 @@ forge_api() { method="$2" shift ;; + -X?*) method="${1#-X}" ;; + --method=*) + method="${1#*=}" + [ -n "$method" ] || { echo "forge_api: --method requires a value" >&2; return 1; } + ;; --jq) jqexpr="$2"; have_jq=true; shift ;; -*) ;; *) [ -n "$endpoint" ] || endpoint="$1" ;; diff --git a/test/forge-backends.test.sh b/test/forge-backends.test.sh index 08adc61..783530f 100644 --- a/test/forge-backends.test.sh +++ b/test/forge-backends.test.sh @@ -825,6 +825,8 @@ check "forge_timeline exhausts all pages despite per-page total headers" 0 "" \ test "$(jq 'length' <<<"$tl")" = 151 check "forge_timeline retains the newest event beyond page one" 0 "" \ jq -e 'any(.[]; .created_at == "event-151")' <<<"$tl" >/dev/null +check "a short final page terminates without an extra empty-page read" 0 "" \ + test "$(wc -l <"$timeline_calls")" = 4 # A collection exactly divisible by the page size needs one final empty read; # stopping after the second full page cannot prove exhaustion. @@ -843,14 +845,23 @@ FAKE_TL_HEADERS=no timeline_stub check "exhaustive pagination needs no x-total-count header" 0 "" \ eq 51 forge_api --paginate-exhaustive 'repos/o/r/issues/188/timeline' --jq 'length' +check "the same missing-header fixture is still refused by strict pagination" 1 \ + "did not send x-total-count" \ + forge_api --paginate 'repos/o/r/issues/188/timeline' --jq 'length' FAKE_TL_HEADERS=yes check "strict and exhaustive pagination are mutually exclusive" 1 "mutually exclusive" \ forge_api --paginate --paginate-exhaustive 'repos/o/r/issues/188/timeline' check "exhaustive pagination refuses a non-GET method" 1 "GET" \ forge_api --paginate-exhaustive -X POST 'repos/o/r/issues/188/timeline' +check "exhaustive pagination refuses compact -XPOST too" 1 "GET" \ + forge_api --paginate-exhaustive -XPOST 'repos/o/r/issues/188/timeline' +check "exhaustive pagination refuses --method=POST too" 1 "GET" \ + forge_api --paginate-exhaustive --method=POST 'repos/o/r/issues/188/timeline' check "the exhaustive flag has exactly one production call site" 0 "" \ test "$(grep -c 'paginate-exhaustive' "$ROOT/lib/forge-forgejo.sh")" = 5 +check "only forge_timeline invokes exhaustive pagination" 0 "" \ + test "$(grep -c 'forge_api --paginate-exhaustive' "$ROOT/lib/forge-forgejo.sh")" = 1 # Unreadable: curl fails. Status must surface through forge_timeline itself # (not a later jq), or the ruling ladder invents a verdict on a half-read.