fix: ovverride store aggregate when newly created
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2024-07-14 18:31:57 +05:30
parent 4c6aa0782e
commit bae971a309
Signed by: realaravinth
GPG key ID: F8F50389936984FF

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;