Closed jackhannah95 closed 4 years ago
one option to test is to create a directory within the inst
folder of your package, e.g. inst/test_files
and then create put a few test files in there. Hopefully you should be able to then use these files to create unit tests - otherwise you will need to experiment with the mockery package which should be able to trick the unit tests into believing there are files actually there when there are not (see https://blog.r-hub.io/2019/10/29/mocking/)
I basically just copied the way readr and readxl do their tests by saving all the files inside the testthat
folder and using testthat::test_path
to refer to them. It seems to work alright so hopefully nothing complicated like mocking will be required, but I found this quite a hard function to think up tests for.
ah didn't know about that, sounds like the best solution so will keep it in mind cheers!
This is mostly creating
file_size
, some tests for it, and adding some files used in the tests. Thinking of tests for this was quite hard so let me know if you have any good ideas.I also created a
phimethods.R
script for some package-level documentatin. It's mainly just to include the lineif(getRversion() >= "2.15.1") utils::globalVariables(c("."))
which stops a note appearing duringR CMD check
about.
being an undefined variable.Also added some code from @alan-y to
.travis.yml
to test on old and development versions of R.