fix: instance remove (#4602)

This commit is contained in:
Livio Spring
2022-10-26 15:06:48 +02:00
committed by GitHub
parent 001636f2b4
commit d721f725fd
89 changed files with 656 additions and 122 deletions

View File

@@ -379,24 +379,28 @@ func TestCRDB_Push_OneAggregate(t *testing.T) {
}},
},
{
name: "push 1 event and add asset",
name: "push 1 event and remove instance unique constraints",
args: args{
ctx: context.Background(),
events: []*repository.Event{
generateEvent(t, "12"),
},
uniqueConstraints: generateRemoveInstanceUniqueConstraints(t, "instanceID"),
uniqueDataType: "usernames",
uniqueDataField: "testremove",
uniqueDataInstanceID: "instanceID",
},
res: res{
wantErr: false,
eventsRes: eventsRes{
pushedEventsCount: 1,
assetCount: 1,
uniqueCount: 0,
aggID: []string{"12"},
aggType: repository.AggregateType(t.Name()),
}},
},
{
name: "push 1 event and remove asset",
name: "push 1 event and add asset",
args: args{
ctx: context.Background(),
events: []*repository.Event{
@@ -407,11 +411,28 @@ func TestCRDB_Push_OneAggregate(t *testing.T) {
wantErr: false,
eventsRes: eventsRes{
pushedEventsCount: 1,
assetCount: 0,
assetCount: 1,
aggID: []string{"13"},
aggType: repository.AggregateType(t.Name()),
}},
},
{
name: "push 1 event and remove asset",
args: args{
ctx: context.Background(),
events: []*repository.Event{
generateEvent(t, "14"),
},
},
res: res{
wantErr: false,
eventsRes: eventsRes{
pushedEventsCount: 1,
assetCount: 0,
aggID: []string{"14"},
aggType: repository.AggregateType(t.Name()),
}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -1201,3 +1222,13 @@ func generateRemoveUniqueConstraint(t *testing.T, table, uniqueField string) *re
return e
}
func generateRemoveInstanceUniqueConstraints(t *testing.T, instanceID string) *repository.UniqueConstraint {
t.Helper()
e := &repository.UniqueConstraint{
InstanceID: instanceID,
Action: repository.UniqueConstraintInstanceRemoved,
}
return e
}