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

Function initTestConfig

rivertest/common_test.go:28–43  ·  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

26// Most workflow examples call this helper to keep setup terse while leaving
27// `pgxpool.New` and `river.NewClient` wiring visible in each example.
28func initTestConfig(ctx context.Context, dbPool *pgxpool.Pool, config *river.Config) *river.Config {
29 if config.Logger == nil {
30 config.Logger = slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
31 Level: slog.LevelWarn,
32 ReplaceAttr: slogutil.NoLevelTime,
33 }))
34 }
35
36 if dbPool != nil {
37 config.Schema = riverdbtest.TestSchema(ctx, testutil.PanicTB(), riverpgxv5.New(dbPool), nil)
38 }
39
40 config.TestOnly = true
41
42 return config
43}

Callers 2

Example_requireInsertedFunction · 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…