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

Function Test_Client_ClientFromContext

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

Source from the content-addressed store, hash-verified

2725}
2726
2727func Test_Client_ClientFromContext(t *testing.T) {
2728 t.Parallel()
2729
2730 ctx := context.Background()
2731
2732 config := newTestConfig(t, "")
2733
2734 type JobArgs struct {
2735 testutil.JobArgsReflectKind[JobArgs]
2736 }
2737
2738 var (
2739 clientResult *Client[pgx.Tx]
2740 jobDoneChan = make(chan struct{})
2741 )
2742 AddWorker(config.Workers, WorkFunc(func(ctx context.Context, job *Job[JobArgs]) error {
2743 clientResult = ClientFromContext[pgx.Tx](ctx)
2744 close(jobDoneChan)
2745 return nil
2746 }))
2747
2748 client := runNewTestClient(ctx, t, config)
2749
2750 _, err := client.Insert(ctx, JobArgs{}, nil)
2751 require.NoError(t, err)
2752
2753 riversharedtest.WaitOrTimeout(t, jobDoneChan)
2754
2755 require.NotNil(t, clientResult)
2756 require.Equal(t, client, clientResult)
2757}
2758
2759func Test_Client_JobDelete(t *testing.T) {
2760 t.Parallel()

Callers

nothing calls this directly

Calls 6

WaitOrTimeoutFunction · 0.92
AddWorkerFunction · 0.85
WorkFuncFunction · 0.85
runNewTestClientFunction · 0.85
InsertMethod · 0.80
newTestConfigFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…