Thanks Maelle. I am still having issues though. It works fine when debugging with load_all()
and works with test()
but not with check()
.
What I have got:
- example_config function in
tests/testthat/helper-config.R
- I have used yours
- config.yml in
tests/testthat/config.yml
- no
inst
folder
- no top level
config.yml
- none of the files in the tests folder are being ignored by
.Rbuildignore
This is an example error:
ββ Failed tests ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ Error (test_age_year_agg.R:5:3): age_year_agg checks ββββββββββββββββββββββββ
Error: Config file config.yml not found in current working directory or parent directories
Backtrace:
β
- ββconfig::get("postgres", file = example_config()) test_age_year_agg.R:5:2
And this is an example of the test:
test_that("test checks", {
# # helper function for connection from 'tests/testthat/helper-config.R'
creds <- config::get("postgres", file = example_config())
CON <- DBI::dbConnect(RPostgres::Postgres(),
host = creds$host,
dbname = creds$dbname,
user = creds$user,
password = creds$password,
port = creds$port)
query <- # the function query that connects to a db
expect_s3_class(query, "data.frame")
})
Do you know what might be wrong and what the solution to this might be?