mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
add tests
This commit is contained in:
parent
520d37983c
commit
41e271974a
4 changed files with 241 additions and 3 deletions
|
@ -1,4 +1,7 @@
|
|||
use std::{panic::{UnwindSafe, catch_unwind, resume_unwind}, time::Duration};
|
||||
use std::{
|
||||
panic::{catch_unwind, resume_unwind, UnwindSafe},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use actix_web::http::StatusCode;
|
||||
use paste::paste;
|
||||
|
@ -185,13 +188,17 @@ impl Index<'_> {
|
|||
self.service.get(url).await
|
||||
}
|
||||
|
||||
pub async fn search(&self, query: Value, test: impl Fn(Value, StatusCode) + UnwindSafe + Clone) {
|
||||
/// Performs both GET and POST search queries
|
||||
pub async fn search(
|
||||
&self,
|
||||
query: Value,
|
||||
test: impl Fn(Value, StatusCode) + UnwindSafe + Clone,
|
||||
) {
|
||||
let (response, code) = self.search_post(query.clone()).await;
|
||||
let t = test.clone();
|
||||
if let Err(e) = catch_unwind(move || t(response, code)) {
|
||||
eprintln!("Error with post search");
|
||||
resume_unwind(e);
|
||||
|
||||
}
|
||||
|
||||
let (response, code) = self.search_get(query).await;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue