mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 13:48:45 +00:00
feat: test event reduction to relational tables (#11718)
# Which Problems Are Solved This PR provides an example for testing DB reduction to relational tables without exploiting integration tests. # How the Problems Are Solved - Set up a disposable embedded Postgres DB used to store the results of the calls to the reducers and verify such results - Add utility method to return transactions from the existing DB pool. These transactions can be used by the single test cases to insert and read data from DB - Add a test to verify that the handler contains the expected reducers (checking also that they are on the right aggregate type) - Add tests to verify the single reduce functions. A parent test creates the required objects to satisfy the foreign key constraints. # Additional Changes - Typo fixed in `postgres.DecodeConfig()` - Discard unneeded `projectionName` parameter for `Executor` function # Additional Context - Closes #11430
This commit is contained in:
@@ -61,7 +61,7 @@ func (p *instanceDomainRelationalProjection) reduceCustomDomainAdded(event event
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-DU0xF", "reduce.wrong.event.type %s", instance.InstanceDomainAddedEventType)
|
||||
}
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, projectionName string) error {
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, _ string) error {
|
||||
tx, ok := ex.(*sql.Tx)
|
||||
if !ok {
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-bXCa6", "reduce.wrong.db.pool %T", ex)
|
||||
@@ -83,7 +83,7 @@ func (p *instanceDomainRelationalProjection) reduceDomainPrimarySet(event events
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-TdEWA", "reduce.wrong.event.type %s", instance.InstanceDomainPrimarySetEventType)
|
||||
}
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, projectionName string) error {
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, _ string) error {
|
||||
tx, ok := ex.(*sql.Tx)
|
||||
if !ok {
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-QnjHo", "reduce.wrong.db.pool %T", ex)
|
||||
@@ -108,7 +108,7 @@ func (p *instanceDomainRelationalProjection) reduceCustomDomainRemoved(event eve
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-Hhcdl", "reduce.wrong.event.type %s", instance.InstanceDomainRemovedEventType)
|
||||
}
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, projectionName string) error {
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, _ string) error {
|
||||
tx, ok := ex.(*sql.Tx)
|
||||
if !ok {
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-58ghE", "reduce.wrong.db.pool %T", ex)
|
||||
@@ -130,7 +130,7 @@ func (p *instanceDomainRelationalProjection) reduceTrustedDomainAdded(event even
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-svHDh", "reduce.wrong.event.type %s", instance.TrustedDomainAddedEventType)
|
||||
}
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, projectionName string) error {
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, _ string) error {
|
||||
tx, ok := ex.(*sql.Tx)
|
||||
if !ok {
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-gx7tQ", "reduce.wrong.db.pool %T", ex)
|
||||
@@ -150,7 +150,7 @@ func (p *instanceDomainRelationalProjection) reduceTrustedDomainRemoved(event ev
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-4K74E", "reduce.wrong.event.type %s", instance.TrustedDomainRemovedEventType)
|
||||
}
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, projectionName string) error {
|
||||
return handler.NewStatement(e, func(ctx context.Context, ex handler.Executer, _ string) error {
|
||||
tx, ok := ex.(*sql.Tx)
|
||||
if !ok {
|
||||
return zerrors.ThrowInvalidArgumentf(nil, "HANDL-D68ap", "reduce.wrong.db.pool %T", ex)
|
||||
|
||||
Reference in New Issue
Block a user