You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There does not currently seem to be a good way to override config parameters for testing.
Assume you have e.g. a Shiny app which records uploads in a storage folder. In production, this is set to some appropriate location via config::get("storage_path"). During unit testing, this value should point to a temporary folder removed after the end of a test_that call. Creating a temporary config.yml in pkg_root/tests/testthat does not seem to be a good idea for various reasons, including potentially parallel test execution. Changing the CWD is not really supported by test_that, as test_path(x) will return x while executing tests and tests/testthat while not executing tests.
It would be good to have some sort of withr style way to override individual variables for the duration of a test, simply to force output into a temporary directory.
For what it's worth, test_that should IMO run tests in tests/testthat in a temporary directory, but that's a different issue. It would still be good to be able to override config::get values within a scope.
The text was updated successfully, but these errors were encountered:
It's not clear what you need here. Advice on how to use testthat? You seem to have a good understanding of that already. A request on modifying config? It's not clear what such a request would be.
There does not currently seem to be a good way to override config parameters for testing.
Assume you have e.g. a Shiny app which records uploads in a storage folder. In production, this is set to some appropriate location via
config::get("storage_path")
. During unit testing, this value should point to a temporary folder removed after the end of atest_that
call. Creating a temporaryconfig.yml
inpkg_root/tests/testthat
does not seem to be a good idea for various reasons, including potentially parallel test execution. Changing the CWD is not really supported by test_that, astest_path(x)
will returnx
while executing tests andtests/testthat
while not executing tests.It would be good to have some sort of withr style way to override individual variables for the duration of a test, simply to force output into a temporary directory.
For what it's worth,
test_that
should IMO run tests intests/testthat
in a temporary directory, but that's a different issue. It would still be good to be able to override config::get values within a scope.The text was updated successfully, but these errors were encountered: