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 TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -76,7 +75,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -107,7 +105,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -138,7 +135,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -175,7 +171,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -189,6 +184,32 @@ func TestIDPLoginPolicyLinkProjection_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(IDPUserLinkInstanceIDCol),
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (instance_id = $1)",
expectedArgs: []interface{}{
"agg-id",
},
},
},
},
},
},
{
name: "org.reduceCascadeRemoved",
args: args{
@@ -206,7 +227,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -234,7 +254,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -261,7 +280,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -290,7 +308,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: org.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -320,7 +337,6 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
aggregateType: instance.AggregateType,
sequence: 15,
previousSequence: 10,
projection: IDPLoginPolicyLinkTable,
executer: &testExecuter{
executions: []execution{
{
@@ -345,7 +361,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
event = tt.args.event(t)
got, err = tt.reduce(event)
assertReduce(t, got, err, tt.want)
assertReduce(t, got, err, IDPLoginPolicyLinkTable, tt.want)
})
}
}