feat(identity): store users, email tokens, and sessions
This commit is contained in:
1 parent
15e2e50561
commit
e7d0d92ef9
30 files changed
+4792
-32
No files matched your search
@@ -7,8 +7,10 @@ import (
|
||||
"crypto/rand"
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
@@ -95,6 +97,23 @@ func (env *testEnvironment) newPoolWithMaxConns(ctx context.Context, t *testing.
|
||||
return pool
|
||||
}
|
||||
|
||||
// newPoolWithLockTimeout opens a pool whose sessions fail a lock wait after
|
||||
// timeout, so a test can prove that a statement never waits for a lock.
|
||||
func (env *testEnvironment) newPoolWithLockTimeout(ctx context.Context, t *testing.T, timeout time.Duration) *pgxpool.Pool {
|
||||
t.Helper()
|
||||
poolConfig, err := pgxpool.ParseConfig(env.Config.DatabaseURL)
|
||||
if err != nil {
|
||||
t.Fatalf("parse bootstrap database URL: %v", err)
|
||||
}
|
||||
poolConfig.ConnConfig.RuntimeParams["lock_timeout"] = strconv.FormatInt(timeout.Milliseconds(), 10)
|
||||
pool, err := pgxpool.NewWithConfig(ctx, poolConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("create PostgreSQL pool with a lock timeout: %v", err)
|
||||
}
|
||||
t.Cleanup(pool.Close)
|
||||
return pool
|
||||
}
|
||||
|
||||
// createIsolatedDatabase creates an empty database in the bootstrap container
|
||||
// for tests that must change the whole schema, and drops it with t.
|
||||
func (env *testEnvironment) createIsolatedDatabase(ctx context.Context, t *testing.T) string {
|
||||
|
||||
Reference in new issue
Block a user