mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
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 <livio.a@gmail.com> Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
"github.com/zitadel/zitadel/internal/repository/project"
|
||||
"github.com/zitadel/zitadel/internal/repository/user"
|
||||
@@ -41,7 +42,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -80,7 +80,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -115,7 +114,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -147,7 +145,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -176,7 +173,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: user.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -203,7 +199,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: org.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -215,6 +210,31 @@ func TestProjectGrantMemberProjection_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.project_grant_members2 WHERE (instance_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.ProjectRemovedEventType",
|
||||
@@ -230,7 +250,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -257,7 +276,6 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
aggregateType: project.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: ProjectGrantMemberProjectionTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -282,7 +300,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
|
||||
event = tt.args.event(t)
|
||||
got, err = tt.reduce(event)
|
||||
assertReduce(t, got, err, tt.want)
|
||||
assertReduce(t, got, err, ProjectGrantMemberProjectionTable, tt.want)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user