fix tests

This commit is contained in:
mpostma 2020-06-10 12:26:36 +02:00
parent 2ada9c5d72
commit ff2490ca8b

View File

@ -1257,8 +1257,9 @@ async fn test_faceted_search_invalid() {
//no faceted attributes set //no faceted attributes set
let query = "q=a&facetFilters=%5B%22color%3Ablue%22,%20%22tags%3Abug%22%20%5D"; let query = "q=a&facetFilters=%5B%22color%3Ablue%22,%20%22tags%3Abug%22%20%5D";
let (_response, status_code) = server.search(query).await; let (response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
let body = json!({ let body = json!({
"attributesForFaceting": ["color", "tags"] "attributesForFaceting": ["color", "tags"]
@ -1268,29 +1269,35 @@ async fn test_faceted_search_invalid() {
// [] // []
let query = "q=a&facetFilters=%5B%5D"; let query = "q=a&facetFilters=%5B%5D";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
// [[]] // [[]]
let query = "q=a&facetFilters=%5B%5B%5D"; let query = "q=a&facetFilters=%5B%5B%5D";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
// ["color:green", []] // ["color:green", []]
let query = "q=a&facetFilters=%5B%22color%3Agreen%22,%20%5B%5D"; let query = "q=a&facetFilters=%5B%22color%3Agreen%22,%20%5B%5D";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
// too much depth // too much depth
// [[[]]] // [[[]]]
let query = "q=a&facetFilters=%5B%5B%5B%5D%5D%5D"; let query = "q=a&facetFilters=%5B%5B%5B%5D%5D%5D";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
// [["color:green", ["color:blue"]]] // [["color:green", ["color:blue"]]]
let query = "q=a&facetFilters=%5B%5B%22color%3Agreen%22,%20%5B%22color%3Ablue%22%5D%5D%5D"; let query = "q=a&facetFilters=%5B%5B%22color%3Agreen%22,%20%5B%22color%3Ablue%22%5D%5D%5D";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
// "color:green" // "color:green"
let query = "q=a&facetFilters=%22color%3Agreen%22"; let query = "q=a&facetFilters=%22color%3Agreen%22";
let (_response, status_code) = server.search(query).await; let (_response, status_code) = server.search(query).await;
assert_ne!(status_code, 202); assert_eq!(status_code, 400);
assert_eq!(response["errorCode"], "invalid_facet");
} }
#[actix_rt::test] #[actix_rt::test]