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

Function Test_Client_QueueGetTx

client_test.go:6363–6423  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6361}
6362
6363func Test_Client_QueueGetTx(t *testing.T) {
6364 t.Parallel()
6365
6366 ctx := context.Background()
6367
6368 type testBundle struct {
6369 executorTx riverdriver.ExecutorTx
6370 schema string
6371 tx pgx.Tx
6372 }
6373
6374 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
6375 t.Helper()
6376
6377 var (
6378 dbPool = riversharedtest.DBPool(ctx, t)
6379 driver = riverpgxv5.New(dbPool)
6380 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
6381 config = newTestConfig(t, schema)
6382 client = newTestClient(t, dbPool, config)
6383 )
6384
6385 tx, err := dbPool.Begin(ctx)
6386 require.NoError(t, err)
6387 t.Cleanup(func() { tx.Rollback(ctx) })
6388
6389 return client, &testBundle{
6390 executorTx: client.driver.UnwrapExecutor(tx),
6391 schema: schema,
6392 tx: tx,
6393 }
6394 }
6395
6396 t.Run("FetchesAnExistingQueue", func(t *testing.T) {
6397 t.Parallel()
6398
6399 client, bundle := setup(t)
6400
6401 queue := testfactory.Queue(ctx, t, bundle.executorTx, &testfactory.QueueOpts{Schema: bundle.schema})
6402
6403 queueRes, err := client.QueueGetTx(ctx, bundle.tx, queue.Name)
6404 require.NoError(t, err)
6405 require.Equal(t, queue.Name, queueRes.Name)
6406
6407 // Not visible outside of transaction.
6408 _, err = client.QueueGet(ctx, queue.Name)
6409 require.Error(t, err)
6410 require.ErrorIs(t, err, ErrNotFound)
6411 })
6412
6413 t.Run("ReturnsErrNotFoundIfQueueDoesNotExist", func(t *testing.T) {
6414 t.Parallel()
6415
6416 client, _ := setup(t)
6417
6418 queueRes, err := client.QueueGet(ctx, "a_queue_that_does_not_exist")
6419 require.Error(t, err)
6420 require.ErrorIs(t, err, ErrNotFound)

Callers

nothing calls this directly

Calls 15

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
QueueFunction · 0.92
newTestClientFunction · 0.85
CleanupMethod · 0.80
QueueGetTxMethod · 0.80
newTestConfigFunction · 0.70
HelperMethod · 0.65
BeginMethod · 0.65
RollbackMethod · 0.65
UnwrapExecutorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…