tests/testthat/test-hooks.R

test_that("onValidate() caches query", {
  pool <- local_db_pool()
  # reset cache from initial creation + validation
  pool$state$validateQuery <- NULL

  con <- poolCheckout(pool)
  withr::defer(poolReturn(con))
  onValidate(con)
  expect_equal(pool$state$validateQuery, "SELECT 1")
})

Try the pool package in your browser

Any scripts or data that you put into this service are public.

pool documentation built on March 7, 2023, 6:49 p.m.