(t *testing.T)
| 6552 | } |
| 6553 | |
| 6554 | func 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), ¬if.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"}`), |
nothing calls this directly
no test coverage detected
searching dependent graphs…