Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting aggregate version after snapshot was loaded #416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

totemcaf
Copy link

Description

When an aggregate is loaded from a Snapshot, and no additional events are applied, the version is left in 0.

Affected Components

  • events.AggregateStore

Related Issues

#414

Solution and Design

After the snapshot was read from DB and applied to the Aggregate, the aggregate version is set to the corresponding to the Snapshot:

a.SetAggregateVersion(snapshot.Version)

Steps to test and verify

See TestAggregateStore_TakeSnapshot_no_additional_events_after_snapshot_was_saved

  1. Create an aggregate
  2. Set a snapshot policy to store every 3 events
  3. Add 3 events to aggregate (same number than policy or a multiple of it)
  4. Save snapshot
  5. Load aggregate from Snapshot
  6. Aggregate version will be 0

@coveralls
Copy link

Coverage Status

coverage: 67.319% (-0.04%) from 67.361%
when pulling 6a31b3c on AltScore:fix/414-set-version-on-snapshot-load
into ac3a972 on looplab:main.

@totemcaf
Copy link
Author

@maxekman can you give a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants