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)
| 45 | // Most workflow examples call this helper to keep setup terse while leaving |
| 46 | // `pgxpool.New` and `river.NewClient` wiring visible in each example. |
| 47 | func 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 | } |
no test coverage detected
searching dependent graphs…