Use snapshot instead of asserts

Co-authored-by: Many the fish <many@meilisearch.com>
This commit is contained in:
Clément Renault 2023-07-25 14:46:23 +02:00 committed by Kerollmops
parent 0e2a5951b4
commit 59201a7852
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -1,3 +1,4 @@
use meili_snap::snapshot;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde_json::{json, Value}; use serde_json::{json, Value};
@ -70,14 +71,14 @@ async fn advanced_facet_search() {
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
assert_eq!(code, 200, "{}", response); snapshot!(code, @"200 OK");
assert_eq!(dbg!(response)["facetHits"].as_array().unwrap().len(), 0); snapshot!(response["facetHits"].as_array().unwrap().len(), @"0");
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "àdventure"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "àdventure"})).await;
assert_eq!(code, 200, "{}", response); snapshot!(code, @"200 OK");
assert_eq!(response["facetHits"].as_array().unwrap().len(), 1); snapshot!(response["facetHits"].as_array().unwrap().len(), @"1");
} }
#[actix_rt::test] #[actix_rt::test]
@ -94,14 +95,14 @@ async fn more_advanced_facet_search() {
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
assert_eq!(code, 200, "{}", response); snapshot!(code, @"200 OK");
assert_eq!(dbg!(response)["facetHits"].as_array().unwrap().len(), 0); snapshot!(response["facetHits"].as_array().unwrap().len(), @"0");
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventure"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventure"})).await;
assert_eq!(code, 200, "{}", response); snapshot!(code, @"200 OK");
assert_eq!(response["facetHits"].as_array().unwrap().len(), 1); snapshot!(response["facetHits"].as_array().unwrap().len(), @"1");
} }
#[actix_rt::test] #[actix_rt::test]