mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 05:07:32 +00:00
feat: add embedded testing server for postgres (#9955)
# Which Problems Are Solved 1. there was no embedded database to run tests against 2. there were no tests for postgres/migrate 3. there was no test setup for repository which starts a client for the embedded database # How the Problems Are Solved 1. postgres/embedded package was added 2. tests were added 3. TestMain was added incl. an example test # Additional Changes none # Additional Context closes #9934 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -9,11 +9,12 @@ import (
|
||||
"github.com/zitadel/zitadel/backend/v3/storage/database/dialect/postgres/migration"
|
||||
)
|
||||
|
||||
type pgxConn struct{ *pgxpool.Conn }
|
||||
type pgxConn struct {
|
||||
*pgxpool.Conn
|
||||
}
|
||||
|
||||
var (
|
||||
_ database.Client = (*pgxConn)(nil)
|
||||
_ database.Migrator = (*pgxConn)(nil)
|
||||
_ database.Client = (*pgxConn)(nil)
|
||||
)
|
||||
|
||||
// Release implements [database.Client].
|
||||
@@ -53,5 +54,10 @@ func (c *pgxConn) Exec(ctx context.Context, sql string, args ...any) error {
|
||||
|
||||
// Migrate implements [database.Migrator].
|
||||
func (c *pgxConn) Migrate(ctx context.Context) error {
|
||||
return migration.Migrate(ctx, c.Conn.Conn())
|
||||
if isMigrated {
|
||||
return nil
|
||||
}
|
||||
err := migration.Migrate(ctx, c.Conn.Conn())
|
||||
isMigrated = err == nil
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user