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

Function TestRequireInserted

rivertest/rivertest_test.go:37–85  ·  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

35// The tests for this function are quite minimal because it uses the same
36// implementation as the `*Tx` variant, so most of the test happens below.
37func TestRequireInserted(t *testing.T) {
38 t.Parallel()
39
40 ctx := context.Background()
41
42 type testBundle struct {
43 dbPool *pgxpool.Pool
44 driver *riverpgxv5.Driver
45 mockT *testutil.MockT
46 schema string
47 schemaOpts *RequireInsertedOpts
48 }
49
50 setup := func(t *testing.T) (*river.Client[pgx.Tx], *testBundle) {
51 t.Helper()
52
53 var (
54 dbPool = riversharedtest.DBPool(ctx, t)
55 driver = riverpgxv5.New(dbPool)
56 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
57 )
58
59 riverClient, err := river.NewClient(driver, &river.Config{
60 Schema: schema,
61 })
62 require.NoError(t, err)
63
64 return riverClient, &testBundle{
65 dbPool: dbPool,
66 driver: driver,
67 mockT: testutil.NewMockT(t),
68 schema: schema,
69 schemaOpts: &RequireInsertedOpts{Schema: schema},
70 }
71 }
72
73 t.Run("VerifiesInsert", func(t *testing.T) {
74 t.Parallel()
75
76 riverClient, bundle := setup(t)
77
78 _, err := riverClient.Insert(ctx, Job1Args{String: "foo"}, nil)
79 require.NoError(t, err)
80
81 job := requireInserted(ctx, t, bundle.driver, &Job1Args{}, bundle.schemaOpts)
82 require.False(t, bundle.mockT.Failed)
83 require.Equal(t, "foo", job.Args.String)
84 })
85}
86
87func TestRequireInsertedTx(t *testing.T) {
88 t.Parallel()

Callers

nothing calls this directly

Calls 9

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
NewClientFunction · 0.92
NewMockTFunction · 0.92
requireInsertedFunction · 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…