From bae971a30955be65733f4dba29c632fa2d6a1f8d Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 14 Jul 2024 18:31:57 +0530 Subject: [PATCH] fix: ovverride store aggregate when newly created --- src/inventory/domain/store_aggregate.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/inventory/domain/store_aggregate.rs b/src/inventory/domain/store_aggregate.rs index 90fe3a2..4ea22d2 100644 --- a/src/inventory/domain/store_aggregate.rs +++ b/src/inventory/domain/store_aggregate.rs @@ -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; -- 2.39.5