mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 03:47:02 +02:00
fix tests + fmt
This commit is contained in:
parent
c984d8d5a5
commit
179969a9e2
10 changed files with 57 additions and 128 deletions
|
@ -69,9 +69,7 @@ impl Server {
|
|||
|
||||
fn get_request(&mut self, url: &str) -> (Value, StatusCode) {
|
||||
eprintln!("get_request: {}", url);
|
||||
let req = http::Request::get(url)
|
||||
.body(Body::empty())
|
||||
.unwrap();
|
||||
let req = http::Request::get(url).body(Body::empty()).unwrap();
|
||||
let res = self.mock.simulate(req).unwrap();
|
||||
let status_code = res.status().clone();
|
||||
|
||||
|
@ -97,7 +95,7 @@ impl Server {
|
|||
(response, status_code)
|
||||
}
|
||||
|
||||
fn post_request_async(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
||||
fn post_request_async(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
||||
eprintln!("post_request_async: {}", url);
|
||||
let (response, status_code) = self.post_request(url, body);
|
||||
assert_eq!(status_code, 202);
|
||||
|
@ -133,9 +131,7 @@ impl Server {
|
|||
|
||||
fn delete_request(&mut self, url: &str) -> (Value, StatusCode) {
|
||||
eprintln!("delete_request: {}", url);
|
||||
let req = http::Request::delete(url)
|
||||
.body(Body::empty())
|
||||
.unwrap();
|
||||
let req = http::Request::delete(url).body(Body::empty()).unwrap();
|
||||
let res = self.mock.simulate(req).unwrap();
|
||||
let status_code = res.status().clone();
|
||||
|
||||
|
@ -154,7 +150,6 @@ impl Server {
|
|||
(response, status_code)
|
||||
}
|
||||
|
||||
|
||||
// // All Routes
|
||||
|
||||
pub fn list_indexes(&mut self) -> (Value, StatusCode) {
|
||||
|
@ -221,12 +216,20 @@ impl Server {
|
|||
}
|
||||
|
||||
pub fn get_document(&mut self, document_id: impl ToString) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/documents/{}", self.uid, document_id.to_string());
|
||||
let url = format!(
|
||||
"/indexes/{}/documents/{}",
|
||||
self.uid,
|
||||
document_id.to_string()
|
||||
);
|
||||
self.get_request(&url)
|
||||
}
|
||||
|
||||
pub fn delete_document(&mut self, document_id: impl ToString) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}/documents/{}", self.uid, document_id.to_string());
|
||||
let url = format!(
|
||||
"/indexes/{}/documents/{}",
|
||||
self.uid,
|
||||
document_id.to_string()
|
||||
);
|
||||
self.delete_request_async(&url)
|
||||
}
|
||||
|
||||
|
@ -443,5 +446,4 @@ impl Server {
|
|||
|
||||
self.add_or_replace_multiple_documents(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ fn delete() {
|
|||
assert_eq!(status_code, 404);
|
||||
}
|
||||
|
||||
|
||||
// Resolve teh issue https://github.com/meilisearch/MeiliSearch/issues/493
|
||||
#[test]
|
||||
fn delete_batch() {
|
||||
|
@ -24,7 +23,7 @@ fn delete_batch() {
|
|||
let (_response, status_code) = server.get_document(419704);
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
let body = serde_json::json!([419704,512200,181812]);
|
||||
let body = serde_json::json!([419704, 512200, 181812]);
|
||||
server.delete_multiple_documents(body);
|
||||
|
||||
let (_response, status_code) = server.get_document(419704);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use serde_json::json;
|
||||
use assert_json_diff::assert_json_eq;
|
||||
use serde_json::json;
|
||||
|
||||
mod common;
|
||||
|
||||
|
@ -413,8 +413,6 @@ fn create_index_failed() {
|
|||
assert_eq!(message, "invalid data");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Resolve issue https://github.com/meilisearch/MeiliSearch/issues/492
|
||||
#[test]
|
||||
fn create_index_with_primary_key_and_index() {
|
||||
|
@ -542,7 +540,6 @@ fn create_index_and_add_indentifier_after() {
|
|||
let (response, status_code) = server.get_index();
|
||||
assert_eq!(status_code, 200);
|
||||
assert_eq!(response["primaryKey"].as_str().unwrap(), "id");
|
||||
|
||||
}
|
||||
|
||||
// Test that it's impossible to change the primary_key
|
||||
|
@ -576,7 +573,6 @@ fn create_index_and_update_indentifier_after() {
|
|||
assert_eq!(response["primaryKey"].as_str().unwrap(), "id");
|
||||
}
|
||||
|
||||
|
||||
// Test that schema inference work well
|
||||
#[test]
|
||||
fn create_index_without_primary_key_and_add_document() {
|
||||
|
@ -607,7 +603,6 @@ fn create_index_without_primary_key_and_add_document() {
|
|||
assert_eq!(response["primaryKey"].as_str().unwrap(), "id");
|
||||
}
|
||||
|
||||
|
||||
// Test search with no primary_key
|
||||
#[test]
|
||||
fn create_index_without_primary_key_and_search() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::convert::Into;
|
||||
use serde_json::json;
|
||||
use assert_json_diff::assert_json_eq;
|
||||
use serde_json::json;
|
||||
use std::convert::Into;
|
||||
|
||||
mod common;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::convert::Into;
|
||||
use assert_json_diff::assert_json_eq;
|
||||
use serde_json::json;
|
||||
use std::convert::Into;
|
||||
|
||||
mod common;
|
||||
|
||||
|
@ -253,7 +253,6 @@ fn write_all_and_update() {
|
|||
assert_json_eq!(expected, response, ordered: false);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_default_settings() {
|
||||
let mut server = common::Server::with_uid("movies");
|
||||
|
|
|
@ -115,9 +115,7 @@ fn send_undefined_rule() {
|
|||
});
|
||||
server.create_index(body);
|
||||
|
||||
let body = json!([
|
||||
"typos",
|
||||
]);
|
||||
let body = json!(["typos",]);
|
||||
|
||||
let (_response, status_code) = server.update_ranking_rules_sync(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
@ -132,9 +130,7 @@ fn send_malformed_custom_rule() {
|
|||
});
|
||||
server.create_index(body);
|
||||
|
||||
let body = json!([
|
||||
"dsc(truc)",
|
||||
]);
|
||||
let body = json!(["dsc(truc)",]);
|
||||
|
||||
let (_response, status_code) = server.update_ranking_rules_sync(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
|
|
@ -19,10 +19,7 @@ fn update_stop_words() {
|
|||
|
||||
// 2 - Update stop words
|
||||
|
||||
let body = json!([
|
||||
"the",
|
||||
"a"
|
||||
]);
|
||||
let body = json!(["the", "a"]);
|
||||
server.update_stop_words(body.clone());
|
||||
|
||||
// 3 - Get all stop words and compare to the previous one
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue