build_mock_url triggers error in check() for packages
datapumpernickel opened this issue · 2 comments
Hi!
thanks for the amazing package. I have been using it extensively to test my API wrapper. However, I am now running into a rather specific problem that might come up in other cases as well.
I am querying and testing a rather long URL, which contains a file-hash. The url in question is: https://comtradeapi.un.org/bulk/v1/file/32/b07f98ee4cfb477c5b86923bbf159d48ca519ccb35c35865b3578b075fc918fb?format=json
The package in question is the dev branch of comtradr: https://github.com/ropensci/comtradr/tree/dev
When I use a mock directory, the CMD check of R returns the following note:
checking for portable file names ... NOTE
Found the following non-portable file path:
comtradr/tests/testthat/goods_bulk/comtradeapi.un.org/bulk/v1/file/32/b07f98ee4cfb477c5b86923bbf159d48ca519ccb35c35865b3578b075fc918fb-7315b4.R
Tarballs are only required to store paths of up to 100 bytes and cannot
store those of more than 256 bytes, with restrictions including to 100
bytes for the final component.
See section ‘Package structure’ in the ‘Writing R Extensions’ manual.
I am wondering if there is a way to make build_mock_url somehow shorten the paths or whether I can just ignore this and make a comment to CRAN that explains this?
Thanks and I hope I did not overlook anything in the documentation on this!
See https://enpiar.com/httptest2/articles/faq.html#how-do-i-fix-non-portable-file-paths for recommendations and examples.
Hi Neal,
sorry, apparently my googling was not very exhaustive... This helped me solve it, however I was a bit thrown aback, that after I added a redactor the response object did not contain any data anymore. I unofrtunately did not have the time to look a bit more at it to see if I am just doing things I am not supposed too, or whether it is a more systematic issue with the package.
The code I used was the following. With a redactor set the response was size 3.7 kb (no data and empty body) without redactor it was 1.2 MB. Otherwise it seemed to be the same response. If I have time in the next weeks I will try to make a more reproducible example (you need an API Key to test this).
In any case this worked out fine, i just copied over the body from a saved response that had one and manually created a valid json. Thanks again for the quick and helpful reply!
httptest2::set_redactor(
function(x){
httptest2::gsub_response(x, "https\\://comtradeapi.un.org/bulk/v1/file/32/",
"")
})
options(httptest2.verbose = TRUE)
httptest2::with_mock_dir('../goods_bulk',{
expect_s3_class(comtradr::ct_get_bulk(reporter = 'ARG',
start_date = '1962',
end_date = "1962",
primary_token = 'test',
verbose = T), 'data.frame')
})