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
+27 -17
View File
@@ -38,7 +38,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -70,7 +69,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -102,7 +100,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -132,7 +129,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -161,7 +157,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -191,7 +186,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -221,7 +215,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -253,7 +246,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -281,7 +273,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{},
},
@@ -301,7 +292,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -330,7 +320,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -361,7 +350,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -391,7 +379,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -430,7 +417,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -462,7 +448,6 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{
{
@@ -490,12 +475,37 @@ func TestLoginNameProjection_reduces(t *testing.T) {
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
projection: LoginNameProjectionTable,
executer: &testExecuter{
executions: []execution{},
},
},
},
{
name: "instance.reduceInstanceRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceRemovedEventType),
instance.AggregateType,
[]byte(`{"name": "Name"}`),
), instance.InstanceRemovedEventMapper),
},
reduce: reduceInstanceRemovedHelper(LoginNameUserInstanceIDCol),
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "DELETE FROM projections.login_names WHERE (instance_id = $1)",
expectedArgs: []interface{}{
"agg-id",
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -507,7 +517,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
event = tt.args.event(t)
got, err = tt.reduce(event)
assertReduce(t, got, err, tt.want)
assertReduce(t, got, err, LoginNameProjectionTable, tt.want)
})
}
}