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
Showing only changes of commit bae971a309 - Show all commits

View file

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