MCPcopy
hub / github.com/riverqueue/river / Test_Client_Insert

Function Test_Client_Insert

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

Source from the content-addressed store, hash-verified

3256}
3257
3258func Test_Client_Insert(t *testing.T) {
3259 t.Parallel()
3260
3261 ctx := context.Background()
3262
3263 type testBundle struct {
3264 dbPool *pgxpool.Pool
3265 schema string
3266 }
3267
3268 setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) {
3269 t.Helper()
3270
3271 var (
3272 dbPool = riversharedtest.DBPool(ctx, t)
3273 driver = riverpgxv5.New(dbPool)
3274 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
3275 config = newTestConfig(t, schema)
3276 client = newTestClient(t, dbPool, config)
3277 )
3278
3279 return client, &testBundle{
3280 dbPool: dbPool,
3281 schema: schema,
3282 }
3283 }
3284
3285 t.Run("Succeeds", func(t *testing.T) {
3286 t.Parallel()
3287
3288 client, _ := setup(t)
3289
3290 insertRes, err := client.Insert(ctx, &noOpArgs{}, nil)
3291 require.NoError(t, err)
3292 jobRow := insertRes.Job
3293 require.Equal(t, 0, jobRow.Attempt)
3294 require.Equal(t, rivercommon.MaxAttemptsDefault, jobRow.MaxAttempts)
3295 require.JSONEq(t, "{}", string(jobRow.Metadata))
3296 require.Equal(t, (&noOpArgs{}).Kind(), jobRow.Kind)
3297 require.Equal(t, PriorityDefault, jobRow.Priority)
3298 require.Equal(t, QueueDefault, jobRow.Queue)
3299 require.Equal(t, []string{}, jobRow.Tags)
3300 })
3301
3302 t.Run("ProducerFetchLimiterCalled", func(t *testing.T) {
3303 t.Parallel()
3304
3305 var (
3306 dbPool = riversharedtest.DBPoolClone(ctx, t)
3307 driver = NewDriverWithoutListenNotify(dbPool)
3308 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
3309 config = newTestConfig(t, schema)
3310 )
3311
3312 client, err := NewClient(driver, config)
3313 require.NoError(t, err)
3314 client.producersByQueueName[QueueDefault].testSignals.Init(t)
3315

Callers

nothing calls this directly

Calls 15

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
DBPoolCloneFunction · 0.92
WaitOrTimeoutFunction · 0.92
LoggerFunction · 0.92
newTestClientFunction · 0.85
NewClientFunction · 0.85
InsertMethod · 0.80
RequireEmptyMethod · 0.80
ShouldTriggerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…