MCPcopy
hub / github.com/jmoiron/sqlx / RunWithSchemaContext

Function RunWithSchemaContext

sqlx_context_test.go:45–67  ·  view source on GitHub ↗
(ctx context.Context, schema Schema, t *testing.T, test func(ctx context.Context, db *DB, t *testing.T))

Source from the content-addressed store, hash-verified

43}
44
45func RunWithSchemaContext(ctx context.Context, schema Schema, t *testing.T, test func(ctx context.Context, db *DB, t *testing.T)) {
46 runner := func(ctx context.Context, db *DB, t *testing.T, create, drop, now string) {
47 defer func() {
48 MultiExecContext(ctx, db, drop)
49 }()
50
51 MultiExecContext(ctx, db, create)
52 test(ctx, db, t)
53 }
54
55 if TestPostgres {
56 create, drop, now := schema.Postgres()
57 runner(ctx, pgdb, t, create, drop, now)
58 }
59 if TestSqlite {
60 create, drop, now := schema.Sqlite3()
61 runner(ctx, sldb, t, create, drop, now)
62 }
63 if TestMysql {
64 create, drop, now := schema.MySQL()
65 runner(ctx, mysqldb, t, create, drop, now)
66 }
67}
68
69func loadDefaultFixtureContext(ctx context.Context, db *DB, t *testing.T) {
70 tx := db.MustBeginTx(ctx, nil)

Callers 15

TestJoinQueryContextFunction · 0.85
TestNilReceiverContextFunction · 0.85
TestNamedQueryContextFunction · 0.85
TestNilInsertsContextFunction · 0.85
TestScanErrorContextFunction · 0.85
TestUsageContextFunction · 0.85
TestEmbeddedMapsContextFunction · 0.85
TestIssue197ContextFunction · 0.85

Calls 4

MultiExecContextFunction · 0.85
PostgresMethod · 0.80
Sqlite3Method · 0.80
MySQLMethod · 0.80

Tested by

no test coverage detected