feat: instance remove (#4345)

* feat(instance): add remove instance event with projections cleanup

* fix(instance): corrected used id to clean up projections

* fix merge

* fix: correct unit test projection names

* fix: current sequence of lists and query for ensuring keypair based projections

Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Stefan Benz
2022-10-20 14:36:52 +02:00
committed by GitHub
co-authored by Livio Spring Fabi
parent 6e89b7d0a1
commit c2a5b785fb
90 changed files with 1548 additions and 426 deletions
@@ -39,7 +39,6 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: InstanceMemberProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -76,7 +75,6 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: InstanceMemberProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -108,7 +106,6 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: InstanceMemberProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -137,7 +134,6 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: InstanceMemberProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -164,7 +160,6 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: InstanceMemberProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -177,6 +172,32 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
},
},
},
{
name: "instance.reduceInstanceRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceRemovedEventType),
instance.AggregateType,
[]byte(`{"name": "Name"}`),
), instance.InstanceRemovedEventMapper),
},
reduce: reduceInstanceRemovedHelper(MemberInstanceID),
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (instance_id = $1)",
expectedArgs: []interface{}{
"agg-id",
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -188,7 +209,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
event = tt.args.event(t)
got, err = tt.reduce(event)
assertReduce(t, got, err, tt.want)
assertReduce(t, got, err, InstanceMemberProjectionTable, tt.want)
})
}
}