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