Closed nathansam closed 1 year ago
File locations are currently hardcoded eg. https://github.com/marioni-group/MethylPipeR/blob/c6fbb68a8c229d0037c942ed54997e4e9a61960f/tests/testthat/test_fitmprmodel.R#L3
These tests won't pass on CRAN and other people's systems. The easiest approach would be to use tempfile() for files you need to create, such as logs and place any (small) datasets you want to use for tests, but not directly expose to the user, in the inst/ directory. Files places in inst/ are moved to the top-level package directory when the package is installed. This approach is used for this file: https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/inst/example.xlsx and then system.file() can be used to dynamically get the location of the file. https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/tests/testthat/test_fix_date_app.R#L10
tempfile()
inst/
system.file()
Tests no longer use hardcoded file locations.
File locations are currently hardcoded eg. https://github.com/marioni-group/MethylPipeR/blob/c6fbb68a8c229d0037c942ed54997e4e9a61960f/tests/testthat/test_fitmprmodel.R#L3
These tests won't pass on CRAN and other people's systems. The easiest approach would be to use
tempfile()
for files you need to create, such as logs and place any (small) datasets you want to use for tests, but not directly expose to the user, in theinst/
directory. Files places ininst/
are moved to the top-level package directory when the package is installed. This approach is used for this file: https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/inst/example.xlsx and thensystem.file()
can be used to dynamically get the location of the file. https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/tests/testthat/test_fix_date_app.R#L10