mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 10:37:32 +00:00
fixup! fixup! fixup! fixup! fixup! fixup! Merge branch 'clean-transactional-propsal' into instance_table
This commit is contained in:
@@ -16,6 +16,7 @@ type Pool interface {
|
||||
|
||||
type PoolTest interface {
|
||||
Pool
|
||||
// MigrateTest is the same as [Migrator] but executes the migrations multiple times instead of only once.
|
||||
MigrateTest(ctx context.Context) error
|
||||
}
|
||||
|
||||
|
@@ -22,5 +22,5 @@ $$ LANGUAGE plpgsql;
|
||||
CREATE TRIGGER trigger_set_updated_at
|
||||
BEFORE UPDATE ON zitadel.instances
|
||||
FOR EACH ROW
|
||||
WHEN (OLD.* IS DISTINCT FROM NEW.*)
|
||||
WHEN (OLD.updated_at IS NOT DISTINCT FROM NEW.updated_at)
|
||||
EXECUTE FUNCTION zitadel.set_updated_at();
|
||||
|
@@ -83,11 +83,6 @@ func (c *pgxPool) Migrate(ctx context.Context) error {
|
||||
|
||||
// Migrate implements [database.PoolTest].
|
||||
func (c *pgxPool) MigrateTest(ctx context.Context) error {
|
||||
// allow multiple migrations
|
||||
// if isMigrated {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
client, err := c.Pool.Acquire(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@@ -123,6 +123,8 @@ func TestCreateInstance(t *testing.T) {
|
||||
instance, err = instanceRepo.Get(ctx,
|
||||
instanceRepo.NameCondition(database.TextOperationEqual, instance.Name),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, tt.instance.ID, instance.ID)
|
||||
require.Equal(t, tt.instance.Name, instance.Name)
|
||||
require.Equal(t, tt.instance.DefaultOrgID, instance.DefaultOrgID)
|
||||
@@ -133,7 +135,6 @@ func TestCreateInstance(t *testing.T) {
|
||||
require.WithinRange(t, instance.CreatedAt, beforeCreate, afterCreate)
|
||||
require.WithinRange(t, instance.UpdatedAt, beforeCreate, afterCreate)
|
||||
require.Nil(t, instance.DeletedAt)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -339,6 +340,7 @@ func TestGetInstance(t *testing.T) {
|
||||
require.Nil(t, instance, returnedInstance)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, returnedInstance.ID, instance.ID)
|
||||
require.Equal(t, returnedInstance.Name, instance.Name)
|
||||
@@ -347,14 +349,13 @@ func TestGetInstance(t *testing.T) {
|
||||
require.Equal(t, returnedInstance.ConsoleClientID, instance.ConsoleClientID)
|
||||
require.Equal(t, returnedInstance.ConsoleAppID, instance.ConsoleAppID)
|
||||
require.Equal(t, returnedInstance.DefaultLanguage, instance.DefaultLanguage)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestListInstance(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
pool, stop, err := newEmbeededDB(ctx)
|
||||
pool, stop, err := newEmbeddedDB(ctx)
|
||||
require.NoError(t, err)
|
||||
defer stop()
|
||||
|
||||
@@ -488,7 +489,6 @@ func TestListInstance(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// ctx := context.Background()
|
||||
t.Cleanup(func() {
|
||||
_, err := pool.Exec(ctx, "DELETE FROM zitadel.instances")
|
||||
require.NoError(t, err)
|
||||
@@ -517,7 +517,6 @@ func TestListInstance(t *testing.T) {
|
||||
require.Equal(t, returnedInstances[i].ConsoleClientID, instance.ConsoleClientID)
|
||||
require.Equal(t, returnedInstances[i].ConsoleAppID, instance.ConsoleAppID)
|
||||
require.Equal(t, returnedInstances[i].DefaultLanguage, instance.DefaultLanguage)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ func runTests(m *testing.M) int {
|
||||
var stop func()
|
||||
var err error
|
||||
ctx := context.Background()
|
||||
pool, stop, err = newEmbeededDB(ctx)
|
||||
pool, stop, err = newEmbeddedDB(ctx)
|
||||
if err != nil {
|
||||
log.Printf("error with embedded postgres database: %v", err)
|
||||
return 1
|
||||
@@ -31,7 +31,7 @@ func runTests(m *testing.M) int {
|
||||
return m.Run()
|
||||
}
|
||||
|
||||
func newEmbeededDB(ctx context.Context) (pool database.PoolTest, stop func(), err error) {
|
||||
func newEmbeddedDB(ctx context.Context) (pool database.PoolTest, stop func(), err error) {
|
||||
connector, stop, err := embedded.StartEmbedded()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("unable to start embedded postgres: %w", err)
|
||||
|
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
old_handler "github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
@@ -22,25 +21,6 @@ func (*instanceRelationalProjection) Name() string {
|
||||
return InstanceRelationalProjectionTable
|
||||
}
|
||||
|
||||
func (*instanceRelationalProjection) Init() *old_handler.Check {
|
||||
return handler.NewTableCheck(
|
||||
handler.NewTable([]*handler.InitColumn{
|
||||
handler.NewColumn(InstanceColumnID, handler.ColumnTypeText),
|
||||
handler.NewColumn(InstanceColumnName, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(InstanceColumnDefaultOrgID, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(InstanceColumnProjectID, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(InstanceColumnConsoleID, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(InstanceColumnConsoleAppID, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(InstanceColumnDefaultLanguage, handler.ColumnTypeText, handler.Default("")),
|
||||
handler.NewColumn(CreatedAt, handler.ColumnTypeTimestamp),
|
||||
handler.NewColumn(UpdatedAt, handler.ColumnTypeTimestamp),
|
||||
handler.NewColumn(DeletedAt, handler.ColumnTypeTimestamp),
|
||||
},
|
||||
handler.NewPrimaryKey(InstanceColumnID),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func (p *instanceRelationalProjection) Reducers() []handler.AggregateReducer {
|
||||
return []handler.AggregateReducer{
|
||||
{
|
||||
|
Reference in New Issue
Block a user