test: assert actual option rejection and Flight dispatch behavior

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
This commit is contained in:
discord9
2026-10-09 18:10:52 +08:00
parent 786bd97984
commit 6b9be922bd
2 changed files with 36 additions and 10 deletions
+8 -5
View File
@@ -758,11 +758,14 @@ mod tests {
.parse()
.unwrap(),
);
assert!(
FlightCraft::do_get(&flight_handler(calls.clone()), request)
.await
.is_ok()
);
let handler = flight_handler(calls.clone());
let response = FlightCraft::do_get(&handler, request).await.unwrap();
let first_item = response
.into_inner()
.next()
.await
.expect("Expected the query result stream to yield an item");
assert_eq!(first_item.unwrap_err().code(), tonic::Code::Internal);
assert_eq!(calls.load(Ordering::SeqCst), 1);
}
+28 -5
View File
@@ -620,14 +620,37 @@ pub async fn test_http_query_options(store_type: StorageType) {
.send()
.await;
assert_eq!(invalid_read_preference.status(), StatusCode::BAD_REQUEST);
let error: ErrorResponse = invalid_read_preference.json().await;
assert_eq!(error.code(), ErrorCode::InvalidArguments as u32);
let error: Value = invalid_read_preference.json().await;
let message = error["error"].as_str().expect("error message");
assert!(
message.contains("Invalid read preference header"),
"unexpected error message: {message}"
);
for hints in ["query.parallelism=0", "query.unsupported_option=true"] {
for (hints, expected_message) in [
(
"query.parallelism=0",
"query.parallelism must be between 1 and 1024",
),
(
"query.unsupported_option=true",
"Unknown or unsupported query option",
),
] {
let response = query(&client, "SHOW VARIABLES query.parallelism", Some(hints)).await;
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
let error: ErrorResponse = response.json().await;
assert_eq!(error.code(), ErrorCode::InvalidArguments as u32);
let error: Value = response.json().await;
let message = error["error"].as_str().expect("error message");
assert!(
message.contains(expected_message),
"unexpected error message for {hints}: {message}"
);
if hints == "query.unsupported_option=true" {
assert!(
message.contains("query.unsupported_option"),
"error message should name the unsupported option: {message}"
);
}
}
guard.remove_all().await;