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

Function initTestConfig

common_test.go:47–63  ·  view source on GitHub ↗

initTestConfig initializes properties on a given River config with defaults suitable for example tests, including an isolated test schema and example-friendly logger. It's meant to keep the main example code more terse and its use can be removed when copy/pasting from examples. This helper is inten

(ctx context.Context, dbPool *pgxpool.Pool, config *river.Config)

Source from the content-addressed store, hash-verified

45// Most workflow examples call this helper to keep setup terse while leaving
46// `pgxpool.New` and `river.NewClient` wiring visible in each example.
47func initTestConfig(ctx context.Context, dbPool *pgxpool.Pool, config *river.Config) *river.Config {
48 if config.Logger == nil {
49 // Keep internal client logs off stdout so doctest output stays stable.
50 config.Logger = slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
51 Level: slog.LevelWarn,
52 ReplaceAttr: slogutil.NoLevelTime,
53 }))
54 }
55
56 if dbPool != nil {
57 config.Schema = riverdbtest.TestSchema(ctx, testutil.PanicTB(), riverpgxv5.New(dbPool), nil)
58 }
59
60 config.TestOnly = true
61
62 return config
63}

Callers 15

Example_uniqueJobFunction · 0.70
Example_jobArgsHooksFunction · 0.70
Example_jobSnoozeFunction · 0.70
Example_subscriptionFunction · 0.70
Example_insertAndWorkFunction · 0.70
Example_periodicJobFunction · 0.70
Example_cronJobFunction · 0.70
Example_batchInsertFunction · 0.70
Example_jobStuckHandlerFunction · 0.70

Calls 3

TestSchemaFunction · 0.92
PanicTBFunction · 0.92
NewFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…