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

Function Test_Client_QueueUpdateTx

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

Source from the content-addressed store, hash-verified

6693}
6694
6695func Test_Client_QueueUpdateTx(t *testing.T) {
6696 t.Parallel()
6697
6698 ctx := context.Background()
6699
6700 type testBundle struct {
6701 executorTx riverdriver.ExecutorTx
6702 schema string
6703 tx pgx.Tx
6704 }
6705
6706 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
6707 t.Helper()
6708
6709 var (
6710 dbPool = riversharedtest.DBPool(ctx, t)
6711 driver = riverpgxv5.New(dbPool)
6712 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
6713 config = newTestConfig(t, schema)
6714 client = newTestClient(t, dbPool, config)
6715 )
6716
6717 tx, err := dbPool.Begin(ctx)
6718 require.NoError(t, err)
6719 t.Cleanup(func() { tx.Rollback(ctx) })
6720
6721 return client, &testBundle{
6722 executorTx: client.driver.UnwrapExecutor(tx),
6723 schema: schema,
6724 tx: tx,
6725 }
6726 }
6727
6728 t.Run("UpdatesQueueMetadata", func(t *testing.T) {
6729 t.Parallel()
6730
6731 client, bundle := setup(t)
6732
6733 queue := testfactory.Queue(ctx, t, bundle.executorTx, &testfactory.QueueOpts{Schema: bundle.schema})
6734 require.Equal(t, []byte(`{}`), queue.Metadata)
6735
6736 queue, err := client.QueueUpdateTx(ctx, bundle.tx, queue.Name, &QueueUpdateParams{
6737 Metadata: []byte(`{"foo":"bar"}`),
6738 })
6739 require.NoError(t, err)
6740 require.JSONEq(t, `{"foo":"bar"}`, string(queue.Metadata))
6741
6742 queue, err = client.QueueUpdateTx(ctx, bundle.tx, queue.Name, &QueueUpdateParams{
6743 Metadata: nil,
6744 })
6745 require.NoError(t, err)
6746 require.JSONEq(t, `{"foo":"bar"}`, string(queue.Metadata))
6747
6748 queue, err = client.QueueUpdateTx(ctx, bundle.tx, queue.Name, &QueueUpdateParams{
6749 Metadata: []byte(`{}`),
6750 })
6751 require.NoError(t, err)
6752 require.JSONEq(t, `{}`, string(queue.Metadata))

Callers

nothing calls this directly

Calls 13

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
QueueFunction · 0.92
newTestClientFunction · 0.85
CleanupMethod · 0.80
QueueUpdateTxMethod · 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…