fix: ovverride store aggregate when newly created #31

Merged
realaravinth merged 1 commit from fix-override-store-aggregate into master 2024-07-14 18:37:11 +05:30

View file

@ -60,13 +60,10 @@ impl Aggregate for Store {
fn apply(&mut self, event: Self::Event) {
match event {
InventoryEvent::StoreAdded(e) => {
*self = StoreBuilder::default()
.name(e.name().into())
.address(e.address().as_ref().map(|s| s.to_string()))
.owner(e.owner().into())
.store_id(e.store_id().clone())
.build()
.unwrap();
self.name = e.name().into();
self.address = e.address().as_ref().map(|s| s.to_string());
self.owner = e.owner().into();
self.store_id = e.store_id().clone();
}
_ => (),
}
@ -74,7 +71,7 @@ impl Aggregate for Store {
}
#[cfg(test)]
mod aggregate_tests {
mod tests {
use std::sync::Arc;
use cqrs_es::test::TestFramework;