From eadc2bfadc0719bb39165f31229cf72fc2cdd8d2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 25 Oct 2026 21:32:56 +0100 Subject: [PATCH] Qdrant search test: the limit is pinned by value at 1, 12 and 200 Co-Authored-By: Claude Sonnet 5.5 --- crates/huginn-daemon/src/index/tests.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/huginn-daemon/src/index/tests.rs b/crates/huginn-daemon/src/index/tests.rs index 855bef6..2e70044 100644 --- a/crates/huginn-daemon/src/index/tests.rs +++ b/crates/huginn-daemon/src/index/tests.rs @@ -1110,6 +1110,15 @@ fn qdrant_search_scores_only_the_members_exactly_and_reads_ids_kinds_and_scores( assert!(body.get("exact").is_none(), "a top-level exact is ignored by Qdrant: {body}"); drop(seen); + // The limit is the caller's by value, across the range top_k takes: no + // constant, clamp or cap sits between the daemon and Qdrant. + for limit in [1, 12, 200] { + let echoing = stub(&[("POST /collections/", 200, r#"{"result":[]}"#)]); + QdrantIndex::new(&echoing.url).search(&name, &[1.0], &["p1".to_owned()], limit, TIME).unwrap(); + let sent: serde_json::Value = serde_json::from_str(&echoing.seen.lock().unwrap()[0].2).expect("the request body is JSON"); + assert_eq!(sent["limit"], limit, "the limit asked for is the limit sent"); + } + let nameless = stub(&[("POST /collections/", 200, r#"{"result":[{"id":"p","score":0.5,"payload":{"kind":"question"}}]}"#)]); assert!(QdrantIndex::new(&nameless.url).search(&name, &[1.0], &[], 1, TIME).is_err()); let failing = stub(&[("POST /collections/", 404, r#"{"status":{"error":"not found"}}"#)]);