Compare commits

...
Author SHA1 Message Date
beardthelion 1f15542e40 test(node): pin task list limit ceiling and default on the cursor handler
Port the #405 regression coverage onto the current cursor-paginated
handler: i64::MAX clamps to the 200 ceiling and an omitted limit falls
back to the 50-row default. Negative-limit behavior is already pinned
by negative_limit_returns_empty.
2026-11-10 10:47:45 -06:00
beardthelion 264713736e Merge remote-tracking branch 'origin/main' into pr-405 2026-11-10 09:34:07 -06:00
Jaime Alfaro Salazar 15b7155529 test(api): test exact limit boundaries for negative and i64::MAX limit requests 2026-09-05 17:41:19 -05:00
Jaime Alfaro Salazar e99eb65962 Fix #399: GET /api/v1/tasks: clamp limit to match siblings; negative limit returns 500 with raw DB error 2026-09-05 16:53:01 -05:00
+54
View File
@@ -1296,6 +1296,60 @@ mod visible_tasks_tests {
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
}
/// An over-ceiling limit caps at MAX_VISIBLE_TASKS rather than scanning or
/// serializing the whole table (#405, adapted to the cursor handler).
#[sqlx::test]
async fn limit_ceiling_caps_at_200(pool: PgPool) {
let state = test_state(pool).await;
for i in 0..201 {
state
.db
.create_task(&task(&format!("ceil-{i}"), None, DELEGATOR))
.await
.unwrap();
}
let resp = list_router(state)
.oneshot(signed_request_as(
DELEGATOR,
Method::GET,
"/api/v1/tasks?limit=9223372036854775807",
Body::empty(),
))
.await
.unwrap();
let body = body_json(resp).await;
assert_eq!(
body["count"], 200,
"i64::MAX must clamp to the 200 ceiling, not scan the table"
);
}
/// An omitted limit falls back to the 50-row default (#405).
#[sqlx::test]
async fn omitted_limit_uses_default_50(pool: PgPool) {
let state = test_state(pool).await;
for i in 0..60 {
state
.db
.create_task(&task(&format!("def-{i}"), None, DELEGATOR))
.await
.unwrap();
}
let resp = list_router(state)
.oneshot(signed_request_as(
DELEGATOR,
Method::GET,
"/api/v1/tasks",
Body::empty(),
))
.await
.unwrap();
let body = body_json(resp).await;
assert_eq!(body["count"], 50, "omitted limit must default to 50");
}
/// A negative limit must clamp to zero through `collect_visible_tasks`,
/// not fall through to the visible set.
#[sqlx::test]