Skip to content

Commit 05f3f82

Browse files
committed
Use retry to wait for postgres db to be available
1 parent 22fa390 commit 05f3f82

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.github/workflows/test-coverage.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,5 @@ jobs:
5858

5959
- name: Test coverage
6060
run: |
61-
# Wait for postgres db to accept connections
62-
Sys.sleep(5)
6361
covr::codecov()
6462
shell: Rscript {0}

DESCRIPTION

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Suggests:
2121
ggplot2,
2222
knitr,
2323
testthat,
24+
retry,
2425
rmarkdown,
2526
RSQLite,
2627
withr

tests/testthat/helper-db.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ get_db_info <- function() {
99
prepare_example_postgres_db <- function() {
1010
info <- get_db_info()
1111
tryCatch({
12-
con <- get_postgres_connection(info$dbname, info$user, info$host)
12+
con <- retry::retry(
13+
get_postgres_connection(info$dbname, info$user, info$host),
14+
until = function(val, cnd) !is.null(val),
15+
max_tries = 25,
16+
interval = 0.2)
1317
add_dummy_data(con)
1418
DBI::dbDisconnect(con)
1519
}, error = function(e) {

0 commit comments

Comments
 (0)