-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from zilverline/add_new_snapshot_command
Add new snapshot command
- Loading branch information
Showing
4 changed files
with
53 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
describe Sequent::Core::AggregateSnapshotter do | ||
class MyEvent < Sequent::Core::Event; end | ||
class MyAggregate < Sequent::Core::AggregateRoot; end | ||
|
||
let(:command_handler) { described_class.new } | ||
let(:event_store) { Sequent::configuration.event_store } | ||
let(:aggregate_id) { Sequent.new_uuid } | ||
|
||
let(:take_snapshot) { Sequent::Core::TakeSnapshot.new(aggregate_id: aggregate_id) } | ||
|
||
around do |example| | ||
commands_handlers = Sequent::configuration.command_handlers | ||
begin | ||
example.run | ||
ensure | ||
Sequent::configuration.command_handlers = commands_handlers | ||
end | ||
end | ||
|
||
before :each do | ||
Sequent::configuration.command_handlers << described_class.new | ||
event_store.commit_events( | ||
Sequent::Core::CommandRecord.new, | ||
[ | ||
[ | ||
Sequent::Core::EventStream.new(aggregate_type: 'MyAggregate', aggregate_id: aggregate_id, snapshot_threshold: 1), | ||
[MyEvent.new(aggregate_id: aggregate_id, sequence_number: 1)] | ||
] | ||
] | ||
) | ||
end | ||
|
||
it 'can take a snapshot' do | ||
Sequent.command_service.execute_commands(*take_snapshot) | ||
|
||
expect(Sequent::Core::EventRecord.last.event_type).to eq Sequent::Core::SnapshotEvent.name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters