feat: add mock implementation for entity catalog
This commit is contained in:
@@ -8,9 +8,12 @@ mod trt;
|
|||||||
mod tst;
|
mod tst;
|
||||||
|
|
||||||
pub use crate::str::attribute::O as Attribute;
|
pub use crate::str::attribute::O as Attribute;
|
||||||
|
pub use crate::str::catalog::O as Catalog;
|
||||||
pub use crate::str::entity::O as Entity;
|
pub use crate::str::entity::O as Entity;
|
||||||
pub use crate::str::value::E as Value;
|
pub use crate::str::value::E as Value;
|
||||||
pub use crate::trt::eav::T as EAV;
|
pub use crate::trt::eav::T as EAV;
|
||||||
pub use crate::trt::from_eav::T as FromEAV;
|
pub use crate::trt::from_eav::T as FromEAV;
|
||||||
pub use crate::trt::to_eav::T as ToEAV;
|
pub use crate::trt::to_eav::T as ToEAV;
|
||||||
pub use crate::trt::to_value::T as ToValue;
|
pub use crate::trt::to_value::T as ToValue;
|
||||||
|
|
||||||
|
pub mod sqlite {}
|
||||||
|
|||||||
31
01.workspace/heave/src/str/catalog.rs
Normal file
31
01.workspace/heave/src/str/catalog.rs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Default, PartialEq, Clone)]
|
||||||
|
pub struct O {
|
||||||
|
path: String,
|
||||||
|
items: std::collections::HashMap<String, Entity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl O {
|
||||||
|
pub fn new(path: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
path: String::from(path),
|
||||||
|
..O::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn persist(&mut self, entity: &mut Entity) {
|
||||||
|
self.items.insert(entity.id.clone(), entity.clone());
|
||||||
|
entity.persisted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// impl std::fmt::Display for O {
|
||||||
|
// fn fmt(&self, _f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
// todo!();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[cfg(test)]
|
||||||
|
// mod unit_tests {
|
||||||
|
// use super::*;
|
||||||
|
// }
|
||||||
@@ -59,10 +59,4 @@ impl O {
|
|||||||
let value = self.value_of(id).unwrap();
|
let value = self.value_of(id).unwrap();
|
||||||
T::from(value.clone())
|
T::from(value.clone())
|
||||||
}
|
}
|
||||||
pub fn persist(&self) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
pub fn load(_id: &str) -> Self {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod attribute;
|
pub mod attribute;
|
||||||
|
pub mod catalog;
|
||||||
pub mod entity;
|
pub mod entity;
|
||||||
pub mod value;
|
pub mod value;
|
||||||
|
|||||||
@@ -122,4 +122,15 @@ mod tests {
|
|||||||
let converted_product = Product::from_eav(entity);
|
let converted_product = Product::from_eav(entity);
|
||||||
assert_eq!(expected_product, converted_product);
|
assert_eq!(expected_product, converted_product);
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn check_007() {
|
||||||
|
let mut catalog = Catalog::new("");
|
||||||
|
let product = Product {
|
||||||
|
id: short_uuid::short!().to_string(),
|
||||||
|
name: "laptop".to_string(),
|
||||||
|
price: 200000u64,
|
||||||
|
};
|
||||||
|
let mut entity = product.to_eav();
|
||||||
|
catalog.persist(&mut entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user