MCPcopy Create free account
hub / github.com/riverqueue/river / TestRequireNotInserted

Function TestRequireNotInserted

rivertest/rivertest_test.go:391–438  ·  view source on GitHub ↗

The tests for this function are quite minimal because it uses the same implementation as the `*Tx` variant, so most of the test happens below.

(t *testing.T)

Source from the content-addressed store, hash-verified

389// The tests for this function are quite minimal because it uses the same
390// implementation as the `*Tx` variant, so most of the test happens below.
391func TestRequireNotInserted(t *testing.T) {
392 t.Parallel()
393
394 ctx := context.Background()
395
396 type testBundle struct {
397 dbPool *pgxpool.Pool
398 driver *riverpgxv5.Driver
399 mockT *testutil.MockT
400 schema string
401 schemaOpts *RequireInsertedOpts
402 }
403
404 setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) {
405 t.Helper()
406
407 var (
408 dbPool = riversharedtest.DBPool(ctx, t)
409 driver = riverpgxv5.New(dbPool)
410 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
411 )
412
413 riverClient, err := river.NewClient(driver, &river.Config{
414 Schema: schema,
415 })
416 require.NoError(t, err)
417
418 return riverClient, &testBundle{
419 dbPool: dbPool,
420 driver: driver,
421 mockT: testutil.NewMockT(t),
422 schema: schema,
423 schemaOpts: &RequireInsertedOpts{Schema: schema},
424 }
425 }
426
427 t.Run("VerifiesNotInsert", func(t *testing.T) {
428 t.Parallel()
429
430 riverClient, bundle := setup(t)
431
432 _, err := riverClient.Insert(ctx, Job2Args{Int: 123}, nil)
433 require.NoError(t, err)
434
435 requireNotInserted(ctx, t, bundle.driver, &Job1Args{}, bundle.schemaOpts)
436 require.False(t, bundle.mockT.Failed)
437 })
438}
439
440func TestRequireNotInsertedTx(t *testing.T) {
441 t.Parallel()

Callers

nothing calls this directly

Calls 9

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
NewClientFunction · 0.92
NewMockTFunction · 0.92
requireNotInsertedFunction · 0.85
InsertMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…