nealrichardson / httptest

A Test Environment for HTTP Requests in R
https://enpiar.com/r/httptest/
Other
79 stars 10 forks source link

naive question: why do the redactor and request functions live in inst/httptest? #41

Closed maelle closed 3 years ago

maelle commented 3 years ago

When setting up httptest one needs to tweak

Why can't the the redactor and request function be defined in the helper.R instead? Alternatively, could use_httptest() create them even if they're empty?

nealrichardson commented 3 years ago

They're in inst so that they're installed with the package. That way, packages that depend on your API-wrapping package can write tests safely and consistently and not leak auth secrets. Perhaps not a problem for many, but it was a problem I had at the time of writing this feature.

Why can't the the redactor and request function be defined in the helper.R instead?

They totally can be using set_requester()/set_redactor(), if you prefer that way and aren't concerned about packages depending on yours.

maelle commented 3 years ago

Oooh I see. Any example I could refer to?

nealrichardson commented 3 years ago

At the time I was developing the crunch package that wrapped the platform's API, and then crplyr on top of that that implemented dplyr methods. In the redactor for crunch, it does things like truncate long UUIDs and otherwise handles quirks of the Crunch HTTP API underneath. crplyr uses the same API so it made sense that it would use the same redactor, and it seemed like the responsibility of the "official" API wrapping package to own how to test/sanitize its API.

(Disclaimer: I haven't been involved with these packages for the last year and a half, so I can't say with certainty how they work now, but it appears they're still generally set up the same.)

nealrichardson commented 3 years ago

Can I close this, or are there docs that should be updated to capture this discussion?

maelle commented 3 years ago

we can close this, sorry and thank you!!