add test get document displayed attributes

This commit is contained in:
mpostma 2021-03-15 10:36:12 +01:00
parent adc71a70ce
commit 77c0a0fba5
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
2 changed files with 22 additions and 0 deletions

View File

@ -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())

View File

@ -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());
}