MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / OpenPreparedTestDB

Function OpenPreparedTestDB

internal/testutil/db.go:24–50  ·  view source on GitHub ↗
(ctx context.Context, dbURL string)

Source from the content-addressed store, hash-verified

22}
23
24func OpenPreparedTestDB(ctx context.Context, dbURL string) (*pgxpool.Pool, error) {
25 if dbURL == "" {
26 dbURL = defaultTestDBURL
27 }
28
29 pool, err := pgxpool.New(ctx, dbURL)
30 if err != nil {
31 return nil, err
32 }
33
34 if err := pool.Ping(ctx); err != nil {
35 pool.Close()
36 return nil, err
37 }
38
39 if err := runMigrations(ctx, pool); err != nil {
40 pool.Close()
41 return nil, err
42 }
43
44 if err := truncateAll(ctx, pool); err != nil {
45 pool.Close()
46 return nil, err
47 }
48
49 return pool, nil
50}
51
52func TestDB(t *testing.T) *pgxpool.Pool {
53 t.Helper()

Callers 2

TestDBFunction · 0.85
StartContractServerFunction · 0.85

Calls 3

runMigrationsFunction · 0.85
truncateAllFunction · 0.85
CloseMethod · 0.45

Tested by 1

TestDBFunction · 0.68