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

Function Test_Client_QueueUpdate

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

Source from the content-addressed store, hash-verified

6552}
6553
6554func Test_Client_QueueUpdate(t *testing.T) {
6555 t.Parallel()
6556
6557 ctx := context.Background()
6558
6559 type testBundle struct {
6560 schema string
6561 }
6562
6563 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
6564 t.Helper()
6565
6566 var (
6567 dbPool = riversharedtest.DBPool(ctx, t)
6568 driver = riverpgxv5.New(dbPool)
6569 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
6570 config = newTestConfig(t, schema)
6571 client = newTestClient(t, dbPool, config)
6572 )
6573
6574 return client, &testBundle{
6575 schema: schema,
6576 }
6577 }
6578
6579 t.Run("UpdatesQueueMetadata", func(t *testing.T) {
6580 t.Parallel()
6581
6582 client, bundle := setup(t)
6583 startClient(ctx, t, client)
6584
6585 type metadataUpdatePayload struct {
6586 Action string `json:"action"`
6587 Metadata json.RawMessage `json:"metadata"`
6588 Queue string `json:"queue"`
6589 }
6590 type notification struct {
6591 topic notifier.NotificationTopic
6592 payload metadataUpdatePayload
6593 }
6594 notifyCh := make(chan notification, 10)
6595
6596 handleNotification := func(topic notifier.NotificationTopic, payload string) {
6597 t.Logf("received notification: %s, %q", topic, payload)
6598 notif := notification{topic: topic}
6599 require.NoError(t, json.Unmarshal([]byte(payload), &notif.payload))
6600 notifyCh <- notif
6601 }
6602
6603 sub, err := client.notifier.Listen(ctx, notifier.NotificationTopicControl, handleNotification)
6604 require.NoError(t, err)
6605 t.Cleanup(func() { sub.Unlisten(ctx) })
6606
6607 queue := testfactory.Queue(ctx, t, client.driver.GetExecutor(), &testfactory.QueueOpts{Schema: bundle.schema})
6608 require.Equal(t, []byte(`{}`), queue.Metadata)
6609
6610 queue, err = client.QueueUpdate(ctx, queue.Name, &QueueUpdateParams{
6611 Metadata: []byte(`{"foo":"bar"}`),

Callers

nothing calls this directly

Calls 15

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
QueueFunction · 0.92
WaitOrTimeoutFunction · 0.92
DBPoolCloneFunction · 0.92
newTestClientFunction · 0.85
NewClientFunction · 0.85
CleanupMethod · 0.80
AfterMethod · 0.80
RequireEmptyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…