Merge pull request 'fix: ovverride store aggregate when newly created' (#31) from fix-override-store-aggregate into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #31
This commit is contained in:
commit
07be1ecf20
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue