MCPcopy Index your code
hub / github.com/riverqueue/river / TestDriverRiverLiteLibSQL

Function TestDriverRiverLiteLibSQL

riverdriver/riverdrivertest/driver_test.go:154–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func TestDriverRiverLiteLibSQL(t *testing.T) { //nolint:dupl
155 t.Parallel()
156
157 var (
158 ctx = context.Background()
159 procurePool = func(ctx context.Context, schema string) (any, string) {
160 return riversharedtest.DBPoolLibSQL(ctx, t, schema), "" // could also be `main` instead of empty string
161 }
162 )
163
164 riverdrivertest.Exercise(ctx, t,
165 func(ctx context.Context, t *testing.T, opts *riverdbtest.TestSchemaOpts) (riverdriver.Driver[*sql.Tx], string) {
166 t.Helper()
167
168 if opts == nil {
169 opts = &riverdbtest.TestSchemaOpts{}
170 }
171 opts.ProcurePool = procurePool
172
173 var (
174 // Driver will have its pool set by TestSchema.
175 driver = riversqlite.New(nil)
176 schema = riverdbtest.TestSchema(ctx, t, driver, opts)
177 )
178 return driver, schema
179 },
180 func(ctx context.Context, t *testing.T) (riverdriver.Executor, riverdriver.Driver[*sql.Tx]) {
181 t.Helper()
182
183 // Driver will have its pool set by TestSchema.
184 driver := riversqlite.New(nil)
185
186 tx, _ := riverdbtest.TestTx(ctx, t, driver, &riverdbtest.TestTxOpts{
187 // Unfortunately, the normal test transaction schema sharing has
188 // to be disabled for SQLite. When enabled, there's too much
189 // contention on the shared test databases and operations fail
190 // with `database is locked (5) (SQLITE_BUSY)`, which is a
191 // common concurrency error in SQLite whose recommended
192 // remediation is a backoff and retry. I tried various
193 // techniques like journal_mode=WAL, but it didn't seem to help
194 // enough. SQLite databases are just local files anyway, and
195 // test transactions can still reuse schemas freed by other
196 // tests through TestSchema, so this should be okay performance
197 // wise.
198 DisableSchemaSharing: true,
199
200 ProcurePool: procurePool,
201 })
202 return driver.UnwrapExecutor(tx), driver
203 })
204}
205
206func TestDriverRiverSQLiteModernC(t *testing.T) { //nolint:dupl
207 t.Parallel()

Callers

nothing calls this directly

Calls 7

DBPoolLibSQLFunction · 0.92
ExerciseFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
TestTxFunction · 0.92
HelperMethod · 0.65
UnwrapExecutorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…