mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
add test get document displayed attributes
This commit is contained in:
parent
adc71a70ce
commit
77c0a0fba5
@ -114,6 +114,7 @@ impl Index {
|
||||
None => fields_ids_map.iter().map(|(id, _)| id).collect(),
|
||||
},
|
||||
};
|
||||
|
||||
let internal_id = self
|
||||
.external_documents_ids(&txn)?
|
||||
.get(doc_id.as_bytes())
|
||||
|
@ -1,6 +1,8 @@
|
||||
use crate::common::Server;
|
||||
use crate::common::GetAllDocumentsOptions;
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
// TODO: partial test since we are testing error, amd error is not yet fully implemented in
|
||||
// transplant
|
||||
#[actix_rt::test]
|
||||
@ -147,3 +149,22 @@ async fn test_get_all_documents_attributes_to_retrieve() {
|
||||
assert_eq!(response.as_array().unwrap().len(), 20);
|
||||
assert_eq!(response.as_array().unwrap()[0].as_object().unwrap().keys().count(), 2);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn get_documents_displayed_attributes() {
|
||||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
index.update_settings(json!({"displayedAttributes": ["gender"]})).await;
|
||||
index.load_test_set().await;
|
||||
|
||||
let (response, code) = index.get_all_documents(GetAllDocumentsOptions::default()).await;
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response.as_array().unwrap().len(), 20);
|
||||
assert_eq!(response.as_array().unwrap()[0].as_object().unwrap().keys().count(), 1);
|
||||
assert!(response.as_array().unwrap()[0].as_object().unwrap().get("gender").is_some());
|
||||
|
||||
let (response, code) = index.get_document(0, None).await;
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response.as_object().unwrap().keys().count(), 1);
|
||||
assert!(response.as_object().unwrap().get("gender").is_some());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user