fix: ovverride store aggregate when newly created #31
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue