use edn_derive::Serialize;
use transistor::client::Crux;
use transistor::types::http::{Actions, Order};
use transistor::types::response::EntityTxResponse;
use transistor::types::CruxId;
#[cfg(not(feature = "async"))]
fn entity_tx() -> EntityTxResponse {
let person = Person {
crux__db___id: CruxId::new("hello-history"),
first_name: "Hello".to_string(),
last_name: "World".to_string(),
};
let put_person = Actions::new().append_put(person.clone());
let client = Crux::new("localhost", "3000").http_client();
let _ = client.tx_log(put_person).unwrap();
let tx_body = client.entity_tx(person.crux__db___id).unwrap();
return tx_body;
}
#[test]
#[cfg(not(feature = "async"))]
fn test_entity_history_with_docs() {
let client = Crux::new("localhost", "3000").http_client();
let tx_body = entity_tx();
let docs = client
.entity_history(tx_body.db___id.clone(), Order::Asc, true)
.unwrap();
assert!(docs.history[0].db__doc.is_some())
}
#[test]
#[cfg(not(feature = "async"))]
fn test_entity_history_without_docs() {
let client = Crux::new("localhost", "3000").http_client();
let tx_body = entity_tx();
let docs = client
.entity_history(tx_body.db___id.clone(), Order::Asc, false)
.unwrap();
assert!(docs.history[0].db__doc.is_none())
}
#[cfg(not(feature = "async"))]
fn main() {
let client = Crux::new("localhost", "3000").http_client();
let tx_body = entity_tx();
let _ = client.entity_history(tx_body.db___id.clone(), Order::Asc, true);
let _ = client.entity_history(tx_body.db___id, Order::Asc, false);
}
#[derive(Debug, Clone, Serialize)]
#[allow(non_snake_case)]
pub struct Person {
crux__db___id: CruxId,
first_name: String,
last_name: String,
}