(ctx context.Context, pgURL string)
| 527 | } |
| 528 | |
| 529 | func connectDB(ctx context.Context, pgURL string) (*sql.DB, error) { |
| 530 | db, err := sql.Open("postgres", pgURL) |
| 531 | if err != nil { |
| 532 | return nil, xerrors.Errorf("open: %w", err) |
| 533 | } |
| 534 | pingCtx, cancel := context.WithTimeout(ctx, 5*time.Second) |
| 535 | defer cancel() |
| 536 | if err := db.PingContext(pingCtx); err != nil { |
| 537 | _ = db.Close() |
| 538 | return nil, xerrors.Errorf("ping: %w", err) |
| 539 | } |
| 540 | return db, nil |
| 541 | } |
| 542 | |
| 543 | func startTempPostgresSetURL(ctx context.Context, logger slog.Logger, cfg *devConfig, pgURL *string) (func(), error) { |
| 544 | pgDir := filepath.Join(cfg.configDir, "postgres") |
no test coverage detected