mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 01:35:36 +00:00
test(mcp): pin paging past the end and the per-page summary
From the Pullfrog review of #48: an offset at or past `total` returns an empty page with `next_offset: null`, and every page carries the same `summary` (it covers all rows). Assert both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
parent
db7c90861c
commit
01f181689e
1 changed files with 17 additions and 0 deletions
|
|
@ -357,6 +357,8 @@ fn ownership_tools_read_the_local_database() {
|
|||
json!({"from": "2026-01-30", "to": "2026-02-27", "limit": 2, "offset": next}),
|
||||
);
|
||||
paged.extend(page["changes"].as_array().unwrap().iter().cloned());
|
||||
// The summary covers all rows, so every page carries the same one.
|
||||
assert_eq!(page["summary"], all["summary"], "offset {next}");
|
||||
offset = page["next_offset"].as_u64();
|
||||
}
|
||||
assert_eq!(paged.len() as u64, total);
|
||||
|
|
@ -377,6 +379,21 @@ fn ownership_tools_read_the_local_database() {
|
|||
);
|
||||
assert!(all["summary"]["tickers"].as_u64().unwrap() >= 1, "{all}");
|
||||
|
||||
// Past the end: an empty last page, not an error.
|
||||
for past in [total, total + 5] {
|
||||
let page = client.ok(
|
||||
"get_ownership_changes",
|
||||
json!({"from": "2026-01-30", "to": "2026-02-27", "offset": past}),
|
||||
);
|
||||
assert_eq!(page["total"], total, "offset {past}");
|
||||
assert_eq!(
|
||||
page["changes"].as_array().unwrap().len(),
|
||||
0,
|
||||
"offset {past}"
|
||||
);
|
||||
assert!(page["next_offset"].is_null(), "offset {past}: {page}");
|
||||
}
|
||||
|
||||
let (is_error, body) = client.call(
|
||||
"get_ownership_changes",
|
||||
json!({"from": "2026-01-30", "to": "2026-02-27", "limit": 301}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue