forked from heavy-duty/ceremony
test: close exhaustive pagination review gaps
This commit is contained in:
parent
40ebcea462
commit
1164640a08
2 changed files with 16 additions and 0 deletions
|
|
@ -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" ;;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue