MustOpenSQLDB returns a database/sql DB.
(tb testing.TB, path string)
| 205 | |
| 206 | // MustOpenSQLDB returns a database/sql DB. |
| 207 | func MustOpenSQLDB(tb testing.TB, path string) *sql.DB { |
| 208 | tb.Helper() |
| 209 | d, err := sql.Open("sqlite", path) |
| 210 | if err != nil { |
| 211 | tb.Fatal(err) |
| 212 | } else if _, err := d.ExecContext(context.Background(), `PRAGMA journal_mode = wal;`); err != nil { |
| 213 | tb.Fatal(err) |
| 214 | } else if _, err := d.ExecContext(context.Background(), `PRAGMA busy_timeout = 5000;`); err != nil { |
| 215 | tb.Fatal(err) |
| 216 | } |
| 217 | return d |
| 218 | } |
| 219 | |
| 220 | // MustCloseSQLDB closes a database/sql DB. |
| 221 | func MustCloseSQLDB(tb testing.TB, d *sql.DB) { |